Skip to content

Commit

Permalink
Cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
atgehrhardt committed Jun 19, 2024
1 parent 7d817b6 commit c360d2b
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions examples/filters/dynamic_ollama_vision_filter_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,18 @@ async def inlet(self, body: dict, user: Optional[dict] = None) -> dict:
body = json.loads(body)

model = body.get("model", "")
print(f"MODEL NAME: {model}")

# Get the content of the most recent message
user_message = get_last_user_message(body["messages"])
print("CURRENT MESSAGE:", user_message)

if model in self.valves.model_to_override:
messages = body.get("messages", [])
for message in messages:
if "images" in message:
images.extend(message["images"])
print("IMAGES: True")
llava_response = await self.process_images_with_llava(images, user_message, self.valves.vision_model,self.valves.ollama_base_url)
raw_llava_response = await self.process_images_with_llava(images, user_message, self.valves.vision_model,self.valves.ollama_base_url)
llava_response = f"REPEAT THIS BACK: {raw_llava_response}"
message["content"] = llava_response
print("LLAVA RESPONSE:", llava_response)
message.pop("images", None) # This will safely remove the 'images' key if it exists
else:
print("IMAGES: False")

print(f"""
THIS IS THE BODY OBJECT:
{body}
""")

return body

0 comments on commit c360d2b

Please sign in to comment.