Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
moutasemalakkad committed Jul 16, 2024
1 parent 8289f2f commit d09da66
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
2 changes: 1 addition & 1 deletion vision_agent/lmm/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .lmm import LMM, AzureOpenAILMM, Message, OllamaLMM, OpenAILMM, ClaudeSonnetLMM
from .lmm import LMM, AzureOpenAILMM, ClaudeSonnetLMM, Message, OllamaLMM, OpenAILMM
43 changes: 23 additions & 20 deletions vision_agent/lmm/lmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from pathlib import Path
from typing import Any, Callable, Dict, List, Optional, Union, cast

import anthropic
import requests
from openai import AzureOpenAI, OpenAI
import anthropic
from PIL import Image

import vision_agent.tools as T
Expand Down Expand Up @@ -376,7 +376,6 @@ def generate(

response = response.json()
return response["response"] # type: ignore


class ClaudeSonnetLMM(LMM):
r"""An LMM class for Anthropic's Claude Sonnet model."""
Expand Down Expand Up @@ -422,22 +421,24 @@ def chat(
if "media" in msg:
for media_path in msg["media"]:
encoded_media = self.encode_image(media_path)
content.append({
"type": "image",
"source": {
"type": "base64",
"media_type": "image/png",
"data": encoded_media,
},
})
content.append(
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/png",
"data": encoded_media,
},
}
)
messages.append({"role": msg["role"], "content": content})

response = self.client.messages.create(
model=self.model_name,
max_tokens=self.max_tokens,
temperature=self.temperature,
messages=messages,
**self.kwargs
**self.kwargs,
)
return cast(str, response.content[0].text)

Expand All @@ -450,20 +451,22 @@ def generate(
if media:
for m in media:
encoded_media = self.encode_image(m)
content.append({
"type": "image",
"source": {
"type": "base64",
"media_type": "image/png",
"data": encoded_media,
},
})
content.append(
{
"type": "image",
"source": {
"type": "base64",
"media_type": "image/png",
"data": encoded_media,
},
}
)
response = self.client.messages.create(
model=self.model_name,
max_tokens=self.max_tokens,
temperature=self.temperature,
messages=[{"role": "user", "content": content}],
**self.kwargs
**self.kwargs,
)
return cast(str, response.content[0].text)

Expand Down

0 comments on commit d09da66

Please sign in to comment.