from utils import llama32, stream_response, disp_image, img2base64, ingroq, get_ollama_modelnames, get_groq_modelnames
from utils import llama32pi, rs4llama, merge_images, llama32opi, ocr_reprompt, ollamapi, inollama, client, convert_to_ollama_format, llmpi
from datetime import datetime
from fastcore.all import *
import pathlib
import PIL
= "images/golden_gate.png"; img_loc img_loc
'images/golden_gate.png'
disp_image(img_loc)
= ("Where is the location of place shown in the picture?")
question question
'Where is the location of place shown in the picture?'
= llmpi(question, image_url=img_loc, provider='ollama', model='llama3.2-vision:11b'); result
result # result = ollamapi(question, image_url=img_loc); result
<<Streaming response>>
The location of the place shown in the picture is San Francisco, California. The bridge depicted is the Golden Gate Bridge, which spans the Golden Gate strait and connects the city of San Francisco to Marin County. It is one of the most iconic landmarks in the United States and a symbol of the city’s rich history and culture.
"The location of the place shown in the picture is San Francisco, California. The bridge depicted is the Golden Gate Bridge, which spans the Golden Gate strait and connects the city of San Francisco to Marin County. It is one of the most iconic landmarks in the United States and a symbol of the city's rich history and culture."
= llmpi(question, image_url=img_loc); result result
<<Streaming response>>
The location of the place shown in the picture is San Francisco, California, USA. The Golden Gate Bridge is a famous suspension bridge that spans the Golden Gate strait, which connects the city of San Francisco to Marin County. It is one of the most iconic landmarks in the world and a popular tourist destination.
'The location of the place shown in the picture is San Francisco, California, USA. The Golden Gate Bridge is a famous suspension bridge that spans the Golden Gate strait, which connects the city of San Francisco to Marin County. It is one of the most iconic landmarks in the world and a popular tourist destination.'
result
'The location of the place shown in the picture is San Francisco, California, USA. The Golden Gate Bridge is a famous suspension bridge that spans the Golden Gate strait, which connects the city of San Francisco to Marin County. It is one of the most iconic landmarks in the world and a popular tourist destination.'
= ("What is the current weather in the location "
weather_question " mentioned in the text below: " f"{result}"); weather_question
'What is the current weather in the location mentioned in the text below: The location of the place shown in the picture is San Francisco, California, USA. The Golden Gate Bridge is a famous suspension bridge that spans the Golden Gate strait, which connects the city of San Francisco to Marin County. It is one of the most iconic landmarks in the world and a popular tourist destination.'
print(weather_question)
What is the current weather in the location mentioned in the text below: The location of the place shown in the picture is San Francisco, California, USA. The Golden Gate Bridge is a famous suspension bridge that spans the Golden Gate strait, which connects the city of San Francisco to Marin County. It is one of the most iconic landmarks in the world and a popular tourist destination.
= datetime.now(); current_date
current_date = current_date.strftime("%d %B %Y"); formatted_date formatted_date
'07 January 2025'
= f"""
system_prompt Environment: ipython
Tools: brave_search, wolphram_alpha
Cutting Knowledge Date: December 2023
Today Date: {formatted_date}
"""
print(system_prompt)
Environment: ipython
Tools: brave_search, wolphram_alpha
Cutting Knowledge Date: December 2023
Today Date: 07 January 2025
= [
messages "role": "system", "content": system_prompt},
{"role": "user", "content": weather_question}
{; messages ]
[{'role': 'system',
'content': '\nEnvironment: ipython\nTools: brave_search, wolphram_alpha\nCutting Knowledge Date: December 2023\nToday Date: 07 January 2025\n'},
{'role': 'user',
'content': 'What is the current weather in the location mentioned in the text below: The location of the place shown in the picture is San Francisco, California, USA. The Golden Gate Bridge is a famous suspension bridge that spans the Golden Gate strait, which connects the city of San Francisco to Marin County. It is one of the most iconic landmarks in the world and a popular tourist destination.'}]
='llama3:8b') inollama(messages, model
"I'm an AI, I don't have access to real-time weather data. However, you can use tools like Brave Search or Wolfram Alpha to find out the current weather in San Francisco, California.\n\nAs of my knowledge cutoff date in December 2023, according to Wolfram Alpha, the average temperature in San Francisco ranges from around 48°F (9°C) in January to 67°F (19°C) in August. The city has a mild climate with significant fog and overcast days throughout the year.\n\nPlease note that this information might have changed since my knowledge cutoff date. For the most up-to-date weather information, I recommend using a reliable weather service or checking websites like AccuWeather, Weather.com, or local news sources for current weather conditions in San Francisco."
ingroq(messages)
'<|python_tag|>brave_search.call(query="San Francisco California weather today")'
# ingroq
='llama-3.2-90b-vision-preview') ingroq(messages, model
'<|reserved_special_token_5|>brave_search.call(query="current weather in San Francisco, California, USA")'
='llama3.2-vision:11b'
model= client.chat(model=model, messages=convert_to_ollama_format(messages), options={'temperature':0.5})
resp
resp
ChatResponse(model='llama3.2-vision:11b', created_at='2025-01-07T12:33:01.031559315Z', done=True, done_reason='stop', total_duration=4326969610, load_duration=27923610, prompt_eval_count=127, prompt_eval_duration=4000000, eval_count=160, eval_duration=4292000000, message=Message(role='assistant', content='I\'m not able to provide real-time weather updates or access current weather conditions. However, I can suggest some ways for you to find out the current weather in San Francisco, California:\n\n1. Check online weather websites: You can check websites like accuweather.com, weather.com, or wunderground.com for the current weather conditions in San Francisco.\n2. Use a search engine: You can type "current weather in San Francisco" in a search engine like Google, and it will show you the current weather conditions.\n3. Check a weather app: You can download a weather app on your smartphone to get real-time weather updates for San Francisco.\n\nPlease note that the information provided may not be up-to-date or accurate, and you should always check multiple sources to confirm the weather conditions.', images=None, tool_calls=None))
get_ollama_modelnames()
['minicpm-v:latest',
'llava:13b',
'llama3.2-vision:11b',
'llama3.2-vision:latest',
'qwen:32b',
'qwen:14b',
'openchat:latest',
'llama3.2:latest',
'codestral:latest',
'nomic-embed-text:latest',
'starcoder2:latest',
'llava:latest',
'codegemma:2b',
'mistral-nemo:latest',
'phi3.5:latest',
'qwen2:7b',
'wizardcoder:python',
'llama3:8b']
='llama-3.1-8b-instant') ingroq(messages, model
'<|python_tag|>brave_search.call(query="San Francisco California weather today")'
resp.message
Message(role='assistant', content='I\'m not able to provide real-time weather updates or access current weather conditions. However, I can suggest some ways for you to find out the current weather in San Francisco, California:\n\n1. Check online weather websites: You can check websites like accuweather.com, weather.com, or wunderground.com for the current weather conditions in San Francisco.\n2. Use a search engine: You can type "current weather in San Francisco" in a search engine like Google, and it will show you the current weather conditions.\n3. Check a weather app: You can download a weather app on your smartphone to get real-time weather updates for San Francisco.\n\nPlease note that the information provided may not be up-to-date or accurate, and you should always check multiple sources to confirm the weather conditions.', images=None, tool_calls=None)