configuration: minor improvements / fixes
Could not extend the subclass of 'TypedDict' the way I wanted, so I switched to 'dataclass'.
This commit is contained in:
@@ -30,17 +30,15 @@ def ai(chat: ChatType,
|
||||
Make AI request with the given chat history and configuration.
|
||||
Return AI response and tokens used.
|
||||
"""
|
||||
if not isinstance(config['openai'], dict):
|
||||
raise RuntimeError('Configuration openai is not a dict.')
|
||||
response = openai.ChatCompletion.create(
|
||||
model=config['openai']['model'],
|
||||
model=config.openai.model,
|
||||
messages=chat,
|
||||
temperature=config['openai']['temperature'],
|
||||
max_tokens=config['openai']['max_tokens'],
|
||||
top_p=config['openai']['top_p'],
|
||||
temperature=config.openai.temperature,
|
||||
max_tokens=config.openai.max_tokens,
|
||||
top_p=config.openai.top_p,
|
||||
n=number,
|
||||
frequency_penalty=config['openai']['frequency_penalty'],
|
||||
presence_penalty=config['openai']['presence_penalty'])
|
||||
frequency_penalty=config.openai.frequency_penalty,
|
||||
presence_penalty=config.openai.presence_penalty)
|
||||
result = []
|
||||
for choice in response['choices']: # type: ignore
|
||||
result.append(choice['message']['content'].strip())
|
||||
|
||||
Reference in New Issue
Block a user