mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 02:34:29 +00:00
34 lines
1 KiB
Python
34 lines
1 KiB
Python
import os, sys, traceback
|
|
|
|
sys.path.insert(
|
|
0, os.path.abspath("../..")
|
|
) # Adds the parent directory to the system path
|
|
import litellm
|
|
from dotenv import load_dotenv
|
|
|
|
def generate_text():
|
|
try:
|
|
messages = [
|
|
{
|
|
"role": "user",
|
|
"content": [
|
|
{
|
|
"type": "text",
|
|
"text": "What's in this image?"
|
|
},
|
|
{
|
|
"type": "image_url",
|
|
"image_url": {
|
|
"url": "https://avatars.githubusercontent.com/u/17561003?v=4"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
response = litellm.completion(model="gemini/gemini-pro-vision", messages=messages)
|
|
print(response)
|
|
assert isinstance(response.choices[0].message.content, str) == True
|
|
except Exception as exception:
|
|
raise Exception("An error occurred during text generation:", exception)
|
|
|
|
generate_text()
|