Update crew.py
Browse files
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 |
-
|
|
|
|
| 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=
|
| 62 |
prompt=question
|
| 63 |
)
|
| 64 |
|
|
@@ -85,14 +88,19 @@ def run_crew(question, file_path):
|
|
| 85 |
|
| 86 |
try:
|
| 87 |
client = OpenAI()
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
)
|
| 94 |
-
|
| 95 |
-
return
|
| 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 |
|