from langchain.chat_models import ChatOpenAI
from langchain.schema import HumanMessage

from log10.langchain import Log10Callback
from log10.llm import Log10Config


log10_callback = Log10Callback(log10_config=Log10Config())


messages = [
    HumanMessage(content="You are a ping pong machine"),
    HumanMessage(content="Ping?"),
]

llm = ChatOpenAI(
    model_name="gpt-3.5-turbo",
    callbacks=[log10_callback],
    temperature=0.5,
    tags=["test"],
)
completion = llm.predict_messages(messages, tags=["foobar"])
print(completion)

print(log10_callback.last_completion_url())

llm = ChatOpenAI(
    model_name="gpt-3.5-turbo",
    callbacks=[log10_callback],
    temperature=0.5,
    tags=["test"],
)
messages.append(HumanMessage(content="Pong!"))
completion = llm.predict_messages(messages, tags=["foobar"])
print(completion)

print(log10_callback.last_completion_url())

langchain.schema.HumanMessage langchain.chat_models.ChatOpenAI
[((341, 443), 'langchain.chat_models.ChatOpenAI', 'ChatOpenAI', ([], {'model_name': '"""gpt-3.5-turbo"""', 'callbacks': '[log10_callback]', 'temperature': '(0.5)', 'tags': "['test']"}), "(model_name='gpt-3.5-turbo', callbacks=[log10_callback],\n    temperature=0.5, tags=['test'])\n", (351, 443), False, 'from langchain.chat_models import ChatOpenAI\n'), ((590, 692), 'langchain.chat_models.ChatOpenAI', 'ChatOpenAI', ([], {'model_name': '"""gpt-3.5-turbo"""', 'callbacks': '[log10_callback]', 'temperature': '(0.5)', 'tags': "['test']"}), "(model_name='gpt-3.5-turbo', callbacks=[log10_callback],\n    temperature=0.5, tags=['test'])\n", (600, 692), False, 'from langchain.chat_models import ChatOpenAI\n'), ((244, 295), 'langchain.schema.HumanMessage', 'HumanMessage', ([], {'content': '"""You are a ping pong machine"""'}), "(content='You are a ping pong machine')\n", (256, 295), False, 'from langchain.schema import HumanMessage\n'), ((301, 330), 'langchain.schema.HumanMessage', 'HumanMessage', ([], {'content': '"""Ping?"""'}), "(content='Ping?')\n", (313, 330), False, 'from langchain.schema import HumanMessage\n'), ((724, 753), 'langchain.schema.HumanMessage', 'HumanMessage', ([], {'content': '"""Pong!"""'}), "(content='Pong!')\n", (736, 753), False, 'from langchain.schema import HumanMessage\n'), ((210, 223), 'log10.llm.Log10Config', 'Log10Config', ([], {}), '()\n', (221, 223), False, 'from log10.llm import Log10Config\n')]