forked from log10-io/log10
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlangchain_model_logger.py
More file actions
34 lines (26 loc) · 1006 Bytes
/
langchain_model_logger.py
File metadata and controls
34 lines (26 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from langchain import OpenAI
from langchain.chat_models import ChatAnthropic, ChatOpenAI
from langchain.schema import AIMessage, HumanMessage, SystemMessage
from log10.langchain import Log10Callback
from log10.llm import Log10Config
log10_callback = Log10Callback(log10_config=Log10Config())
messages = [
SystemMessage(content="You are a ping pong machine"),
HumanMessage(content="Ping?"),
AIMessage(content="Pong"),
HumanMessage(content="Ping 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)
llm = ChatAnthropic(model="claude-2", callbacks=[log10_callback], temperature=0.7, tags=["baz"])
llm.predict_messages(messages)
print(completion)
llm = OpenAI(model_name="gpt-3.5-turbo-instruct", callbacks=[log10_callback], temperature=0.5)
completion = llm.predict("You are a ping pong machine.\nPing?\n")
print(completion)