import openai import json from typing import List, Dict from .auth import get_api_key import tiktoken DEFAULT_TEMPERATURE = 0 DEFAULT_MAX_TOKENS = 500 DEFAULT_MODEL = "gpt-3.5-turbo" openai.api_key = get_api_key("AZURE_OPENAI_API_KEY") openai.api_base = "https://xxx.openai.azure.com" # Replace with your ENDPOINT value openai.api_type = "azure" openai.api_version = "2023-05-15" deployment_name = "xxx" # Replace with your DEPLOYMENT-NAME value def send_prompt(messages: str, model: str = DEFAULT_MODEL): """ Send a question to the Chat GPT Bot Args: messages: The messages with the context model: Model used Returns: The response of the bot. """ response = openai.ChatCompletion.create( engine=deployment_name, messages=messages, temperature=DEFAULT_TEMPERATURE, max_tokens=DEFAULT_MAX_TOKENS ) return response['choices'][0]['message']['content']