bstraehle commited on
Commit
2c6f8d9
·
verified ·
1 Parent(s): 2483171

Update crew.py

Browse files
Files changed (1) hide show
  1. crew.py +18 -10
crew.py CHANGED
@@ -12,12 +12,15 @@ from crewai_tools import (
12
  from openai import OpenAI
13
  from openinference.instrumentation.crewai import CrewAIInstrumentor
14
  from phoenix.otel import register
15
- from util import get_final_answer
 
 
16
 
17
  MANAGER_MODEL = "gpt-4.1"
18
  AGENT_MODEL = "gpt-4.1"
19
  FINAL_ANSWER_MODEL = "gpt-4.5-preview"
20
- STT_MODEL = "whisper-1"
 
21
 
22
  # LLM evaluation
23
 
@@ -58,7 +61,7 @@ def run_crew(question, file_path):
58
 
59
  transcript = client.audio.transcriptions.create(
60
  file=open(file_path, "rb"),
61
- model=STT_MODEL,
62
  prompt=question
63
  )
64
 
@@ -85,14 +88,19 @@ def run_crew(question, file_path):
85
 
86
  try:
87
  client = OpenAI()
88
-
89
- transcript = client.audio.transcriptions.create(
90
- file=open(file_path, "rb"),
91
- model=STT_MODEL,
92
- prompt=question
 
 
 
 
 
93
  )
94
-
95
- return transcript.text
96
  except Exception as e:
97
  raise RuntimeError(f"Failed to process image: {str(e)}")
98
 
 
12
  from openai import OpenAI
13
  from openinference.instrumentation.crewai import CrewAIInstrumentor
14
  from phoenix.otel import register
15
+ from util import get_final_answer, get_img_b64
16
+
17
+ ## LLMs
18
 
19
  MANAGER_MODEL = "gpt-4.1"
20
  AGENT_MODEL = "gpt-4.1"
21
  FINAL_ANSWER_MODEL = "gpt-4.5-preview"
22
+ AUDIO_MODEL = "gpt-4o-transcribe"
23
+ IMAGE_MODEL = "gpt-4.1"
24
 
25
  # LLM evaluation
26
 
 
61
 
62
  transcript = client.audio.transcriptions.create(
63
  file=open(file_path, "rb"),
64
+ model=AUDIO_MODEL,
65
  prompt=question
66
  )
67
 
 
88
 
89
  try:
90
  client = OpenAI()
91
+
92
+ img_b64 = get_img_b64(file_path)
93
+
94
+ completion = client.chat.completions.create(
95
+ messages=[{"role": "user",
96
+ "content": [{"type": "text",
97
+ "text": question},
98
+ {"type": "image_url",
99
+ "image_url": {"url": f"data:image/jpeg;base64,{img_b64}"}}]}],
100
+ model=IMAGE_MODEL
101
  )
102
+
103
+ return completion.choices[0].message.content
104
  except Exception as e:
105
  raise RuntimeError(f"Failed to process image: {str(e)}")
106