2024-07-05 01:33:53 +00:00
|
|
|
import json
|
2024-07-12 09:41:56 +00:00
|
|
|
from openai import OpenAI
|
2024-07-09 04:05:40 +00:00
|
|
|
import requests
|
2024-07-12 09:41:56 +00:00
|
|
|
import os
|
|
|
|
def codegeex4(messages_list, temperature=0.2, top_p=0.95):
|
|
|
|
openai_api_key = os.getenv("openai_api_key")
|
|
|
|
openai_api_base = os.getenv("openai_api_base")
|
|
|
|
model_name = os.getenv("model_name")
|
2024-07-09 04:05:40 +00:00
|
|
|
|
2024-07-05 01:33:53 +00:00
|
|
|
|
2024-07-12 09:41:56 +00:00
|
|
|
client = OpenAI(
|
|
|
|
api_key=openai_api_key,
|
|
|
|
base_url=openai_api_base,
|
|
|
|
)
|
2024-07-09 03:37:30 +00:00
|
|
|
|
2024-07-12 09:41:56 +00:00
|
|
|
chat_response = client.chat.completions.create(
|
|
|
|
model=model_name,
|
|
|
|
messages=messages_list,
|
|
|
|
temperature=temperature,
|
|
|
|
top_p=top_p
|
|
|
|
)
|
|
|
|
return chat_response.choices[0].message.content
|