Skip to content

Commit

Permalink
Update test_llm to omit the test when oai config is missing.
Browse files Browse the repository at this point in the history
  • Loading branch information
chinganc committed Nov 19, 2024
1 parent 3dcd504 commit fbb3d40
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions tests/unit_tests/test_llm.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
from opto.utils.llm import AutoGenLLM
from opto.optimizers.utils import print_color

llm = AutoGenLLM()
system_prompt = 'You are a helpful assistant.'
user_prompt = "Hello world."
try:
llm = AutoGenLLM()
system_prompt = 'You are a helpful assistant.'
user_prompt = "Hello world."


messages = [{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt}]
messages = [{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt}]

output = llm(messages=messages)
# Alternatively, you can use the following code:
# output = llm.create(messages=messages)
output = llm(messages=messages)
# Alternatively, you can use the following code:
# output = llm.create(messages=messages)

response = output.choices[0].message.content
response = output.choices[0].message.content


print_color(f'System: {system_prompt}', 'red')
print_color(f'User: {user_prompt}', 'blue')
print_color(f'LLM: {response}', 'green')
print_color(f'System: {system_prompt}', 'red')
print_color(f'User: {user_prompt}', 'blue')
print_color(f'LLM: {response}', 'green')
except FileNotFoundError as e:
print_color(f'Error: {e}', 'red')
print_colorf('Omit the test.', 'yellow')

0 comments on commit fbb3d40

Please sign in to comment.