Added model selection to .env and update readme

This commit is contained in:
Sander Hilven
2023-09-01 10:34:12 +02:00
parent 660047a071
commit a4d520763f
3 changed files with 5 additions and 8 deletions

View File

@@ -43,7 +43,7 @@ Obviously, it still can't create any production-ready app but the general concep
5. `pip install -r requirements.txt` (install the dependencies)
6. `cd pilot`
7. `mv .env.example .env` (create the .env file)
8. Add your OpenAI API key and the database info to the `.env` file
8. Add your environment (OpenAI/Azure), your API key and the database info to the `.env` file
9. `python db_init.py` (initialize the database)
10. `python main.py` (start GPT Pilot)

View File

@@ -3,7 +3,8 @@ ENDPOINT=OPENAI
OPENAI_API_KEY=
AZURE_API_KEY=
AZURE_ENDPOINT=
AZURE_MODEL_NAME=
#In case of Azure endpoint, change this to your deployed model name
MODEL_NAME=gpt-4
DB_NAME=gpt-pilot
DB_HOST=localhost
DB_PORT=5432

View File

@@ -46,13 +46,9 @@ def get_tokens_in_messages(messages: List[str]) -> int:
tokenized_messages = [tokenizer.encode(message['content']) for message in messages]
return sum(len(tokens) for tokens in tokenized_messages)
# Check if the ENDPOINT is AZURE
#get endpoint and model name from .ENV file
model = os.getenv('MODEL_NAME')
endpoint = os.getenv('ENDPOINT')
if endpoint == 'AZURE':
# If yes, get the model name from .ENV file
model = os.getenv('AZURE_MODEL_NAME')
else:
model="gpt-4"
def num_tokens_from_functions(functions, model=model):
"""Return the number of tokens used by a list of functions."""