alanchen1115 commited on
Commit
251fb1a
·
verified ·
1 Parent(s): 2d5d2a3

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +6 -4
main.py CHANGED
@@ -147,9 +147,11 @@ def analyze_image_with_text(image_path: str, user_text: str) -> str:
147
 
148
  img_user = PIL.Image.open(image_path)
149
 
150
- chat_model = client.chats.create(model="gemini-2.0-flash-exp", temperature=0.5, top_p=0.5,top_k=16)
 
 
 
151
 
152
- response = chat_model.send_message([img_usr, user_text])
153
  if (response.text != None):
154
  out = response.text
155
  else:
@@ -174,8 +176,8 @@ llm = ChatGoogleGenerativeAI(google_api_key=google_api, model="gemini-2.0-flash"
174
  # 建立提示模板
175
  prompt_template = ChatPromptTemplate.from_messages([
176
  ("system", "你是一個強大的助理,可以根據用戶的請求使用提供的工具。"),
177
- ("user", "{agent_input}"),
178
- ("placeholder", {'agent_scratchpad'}),
179
  ])
180
 
181
  # 建立代理人
 
147
 
148
  img_user = PIL.Image.open(image_path)
149
 
150
+ response = genai_client.models.generate_content(
151
+ model="gemini-2.0-flash-exp",
152
+ contents=[img_user, user_text]
153
+ )
154
 
 
155
  if (response.text != None):
156
  out = response.text
157
  else:
 
176
  # 建立提示模板
177
  prompt_template = ChatPromptTemplate.from_messages([
178
  ("system", "你是一個強大的助理,可以根據用戶的請求使用提供的工具。"),
179
+ ("user", "{input}"),
180
+ ("placeholder", {"agent_scratchpad"}),
181
  ])
182
 
183
  # 建立代理人