Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add other ollama visual llms #191

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions operate/models/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ async def get_next_action(model, messages, objective, session_id):
return "coming soon"
if model == "gemini-pro-vision":
return call_gemini_pro_vision(messages, objective), None
if model == "llava":
operation = call_ollama_llava(messages)
if "llava" in model:
operation = call_ollama_llava(messages, model)
return operation, None
if model == "claude-3":
operation = await call_claude_3_with_ocr(messages, objective, model)
Expand Down Expand Up @@ -453,9 +453,11 @@ async def call_gpt_4_vision_preview_labeled(messages, objective, model):
return call_gpt_4_vision_preview(messages)


def call_ollama_llava(messages):
def call_ollama_llava(messages, model):
if model == "":
model = "llava"
if config.verbose:
print("[call_ollama_llava]")
print(f"[call_ollama_llava] model {model}")
time.sleep(1)
try:
screenshots_dir = "screenshots"
Expand Down Expand Up @@ -485,7 +487,7 @@ def call_ollama_llava(messages):
messages.append(vision_message)

response = ollama.chat(
model="llava",
model=model,
messages=messages,
)

Expand Down Expand Up @@ -518,7 +520,7 @@ def call_ollama_llava(messages):

except Exception as e:
print(
f"{ANSI_GREEN}[Self-Operating Computer]{ANSI_BRIGHT_MAGENTA}[llava] That did not work. Trying again {ANSI_RESET}",
f"{ANSI_GREEN}[Self-Operating Computer]{ANSI_BRIGHT_MAGENTA}[{model}] That did not work. Trying again {ANSI_RESET}",
e,
)
print(
Expand All @@ -527,7 +529,7 @@ def call_ollama_llava(messages):
)
if config.verbose:
traceback.print_exc()
return call_ollama_llava(messages)
return call_ollama_llava(messages, model)


async def call_claude_3_with_ocr(messages, objective, model):
Expand Down