mirror of
https://github.com/katanemo/plano.git
synced 2026-05-03 21:02:56 +02:00
Revert "Add support for multiple LLM Providers (#60)"
This reverts commit bd8206742a.
This commit is contained in:
parent
d970b214f4
commit
43d6bc80e9
12 changed files with 127 additions and 456 deletions
|
|
@ -6,31 +6,27 @@ from dotenv import load_dotenv
|
|||
|
||||
load_dotenv()
|
||||
|
||||
OPENAI_API_KEY=os.getenv("OPENAI_API_KEY")
|
||||
MISTRAL_API_KEY = os.getenv("MISTRAL_API_KEY")
|
||||
OPEN_API_KEY=os.getenv("OPENAI_API_KEY")
|
||||
CHAT_COMPLETION_ENDPOINT = os.getenv("CHAT_COMPLETION_ENDPOINT")
|
||||
MODEL_NAME = os.getenv("MODEL_NAME", "gpt-3.5-turbo")
|
||||
|
||||
log.info("CHAT_COMPLETION_ENDPOINT: ", CHAT_COMPLETION_ENDPOINT)
|
||||
|
||||
client = OpenAI(api_key=OPENAI_API_KEY, base_url=CHAT_COMPLETION_ENDPOINT)
|
||||
client = OpenAI(api_key=OPEN_API_KEY, base_url=CHAT_COMPLETION_ENDPOINT)
|
||||
|
||||
def predict(message, history):
|
||||
# history_openai_format = []
|
||||
# for human, assistant in history:
|
||||
# history_openai_format.append({"role": "user", "content": human })
|
||||
# history_openai_format.append({"role": "assistant", "content":assistant})
|
||||
history.append({"role": "user", "content": message})
|
||||
log.info("CHAT_COMPLETION_ENDPOINT: ", CHAT_COMPLETION_ENDPOINT)
|
||||
log.info("history: ", history)
|
||||
|
||||
# Custom headers
|
||||
custom_headers = {
|
||||
'x-bolt-openai-api-key': f"{OPENAI_API_KEY}",
|
||||
'x-bolt-mistral-api-key': f"{MISTRAL_API_KEY}",
|
||||
}
|
||||
|
||||
try:
|
||||
response = client.chat.completions.create(model=MODEL_NAME,
|
||||
messages= history,
|
||||
temperature=1.0,
|
||||
headers=custom_headers
|
||||
temperature=1.0
|
||||
)
|
||||
except Exception as e:
|
||||
log.info(e)
|
||||
|
|
@ -40,6 +36,10 @@ def predict(message, history):
|
|||
log.info("Error calling gateway API: {}".format(e.message))
|
||||
raise gr.Error("Error calling gateway API: {}".format(e.message))
|
||||
|
||||
# for chunk in response:
|
||||
# if chunk.choices[0].delta.content is not None:
|
||||
# partial_message = partial_message + chunk.choices[0].delta.content
|
||||
# yield partial_message
|
||||
choices = response.choices
|
||||
message = choices[0].message
|
||||
content = message.content
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue