1313
1414from amadeusgpt .programs .sandbox import Sandbox
1515from amadeusgpt .utils import AmadeusLogger , QA_Message , create_qa_message
16+ from amadeusgpt .utils .openai_adapter import OpenAIAdapter
1617
1718from .base import AnalysisObject
1819
@@ -22,6 +23,7 @@ class LLM(AnalysisObject):
2223 prices = {
2324 "gpt-4o" : {"input" : 5 / 10 ** 6 , "output" : 15 / 10 ** 6 },
2425 "gpt-4o-mini" : {"input" : 0.15 / 10 ** 6 , "output" : 0.6 / 10 ** 6 },
26+ "thudm/glm-z1-32b:free" : {"input" : 0 , "output" : 0 },
2527 }
2628 total_cost = 0
2729
@@ -65,17 +67,17 @@ def connect_gpt_oai_1(self, messages, **kwargs):
6567 This is routed to openai > 1.0 interfaces
6668 """
6769
68- if self .config .get ("use_streamlit" , False ):
69- if "OPENAI_API_KEY" in os .environ :
70- openai .api_key = os .environ ["OPENAI_API_KEY" ]
71- else :
72- openai .api_key = os .environ ["OPENAI_API_KEY" ]
70+ # if self.config.get("use_streamlit", False):
71+ # if "OPENAI_API_KEY" in os.environ:
72+ # openai.api_key = os.environ["OPENAI_API_KEY"]
73+ # else:
74+ # openai.api_key = os.environ["OPENAI_API_KEY"]
7375 response = None
7476 # gpt_model is default to be the cls.gpt_model, which can be easily set
75- gpt_model = self .gpt_model
77+ # gpt_model = self.gpt_model
7678 # in streamlit app, "gpt_model" is set by the text box
7779
78- client = OpenAI ()
80+ client = OpenAIAdapter (). get_client ()
7981
8082 if self .config .get ("use_streamlit" , False ):
8183 if "gpt_model" in st .session_state :
@@ -89,7 +91,7 @@ def connect_gpt_oai_1(self, messages, **kwargs):
8991
9092 # the usage was recorded from the last run. However, since we have many LLMs that
9193 # share the call of this function, we will need to store usage and retrieve them from the database class
92- num_retries = 3
94+ num_retries = 1
9395 for _ in range (num_retries ):
9496 try :
9597 json_data = {
@@ -259,7 +261,7 @@ def speak(self, sandbox: Sandbox, image: np.ndarray):
259261 multi_image_content = multi_image_content ,
260262 in_place = True ,
261263 )
262- response = self .connect_gpt (self .context_window , max_tokens = 2000 )
264+ response = self .connect_gpt (self .context_window , max_tokens = 20000 )
263265 text = response .choices [0 ].message .content .strip ()
264266
265267 print ("description of the image frame provided" )
@@ -319,7 +321,7 @@ def speak(
319321
320322 self .update_history ("user" , query )
321323
322- response = self .connect_gpt (self .context_window , max_tokens = 2000 )
324+ response = self .connect_gpt (self .context_window , max_tokens = 20000 )
323325 text = response .choices [0 ].message .content .strip ()
324326 # need to keep the memory of the answers from LLM
325327 self .update_history ("assistant" , text )
@@ -374,7 +376,7 @@ def speak(self, qa_message):
374376Can you correct the code? Make sure you only write one function which is the updated function.
375377"""
376378 self .update_history ("user" , query )
377- response = self .connect_gpt (self .context_window , max_tokens = 4096 )
379+ response = self .connect_gpt (self .context_window , max_tokens = 20000 )
378380 text = response .choices [0 ].message .content .strip ()
379381 print (text )
380382 pattern = r"```python(.*?)```"
0 commit comments