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 support for LLaVa #17

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add streaming responses to describe_image
dsibilio committed Sep 12, 2024
commit 3e32f25120a6b09866d2fd8c816e0b4fd45c33d9
4 changes: 3 additions & 1 deletion alfresco_ai_assistant.py
Original file line number Diff line number Diff line change
@@ -183,7 +183,9 @@ def describe_image(document_title: str, user_prompt: str) -> str:
"""Explain, describe, analyze an image. Requires the whole, unprocessed, user prompt/input."""
document = get_document_content(document_title)
image_b64 = base64.b64encode(document["content"]).decode("utf-8")
return vision_llm.invoke(user_prompt if user_prompt else "Describe the image.", images=[image_b64])
response = vision_llm.stream(user_prompt if user_prompt else "Describe the image.", images=[image_b64])
st.write_stream(response)
return None

tools = [discovery, transform_content, translate_content, redact_content, list_recent_content_snippets, copy_file, create_pdf_report, describe_image]
rendered_tools = render_text_description(tools)
11 changes: 10 additions & 1 deletion commons.py
Original file line number Diff line number Diff line change
@@ -61,7 +61,16 @@ def load_llm(llm_name: str, logger=BaseLogger(), config={}):
)
elif llm_name == "llava":
logger.info("LLM: Using Llava")
return Ollama(base_url=config["ollama_base_url"], model="llava")
return ChatOllama(
temperature=0,
base_url=config["ollama_base_url"],
model="llava",
streaming=True,
# seed=2,
top_k=10, # A higher value (100) will give more diverse answers, while a lower value (10) will be more conservative.
top_p=0.3, # Higher value (0.95) will lead to more diverse text, while a lower value (0.5) will generate more focused text.
num_ctx=3072, # Sets the size of the context window used to generate the next token.
)
elif len(llm_name):
logger.info(f"LLM: Using Ollama: {llm_name}")
return ChatOllama(