-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_run_multiple.py
More file actions
31 lines (28 loc) · 942 Bytes
/
example_run_multiple.py
File metadata and controls
31 lines (28 loc) · 942 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
from hyperchain.prompt_templates import StringTemplate
from hyperchain.chain import LLMChain
from hyperchain.llm_runners import OpenAIRunner
template = StringTemplate("Question: {question}\nAnswer:\n")
llm_chain = LLMChain(
template=template,
llm_runner=OpenAIRunner(
model="gpt-3.5-turbo-instruct",
api_key="ENTER API KEY HERE OR IN ENV VARIABLE",
model_params={"max_tokens": 40},
),
)
print(llm_chain.run(question="What is APR?")) # Run one querry
print(
llm_chain.run_multiple(
{"question": "Tell me about APR (Automatic Program Repair)"},
{"question": "Tell me about python"},
{"question": "Tell me about machine learning"},
)
) # Run multiple at the same time
print(
llm_chain.run_multiple(
*list(
{"question": "Tell me about APR (Automatic Program Repair)"}
for _ in range(30)
)
)
) # Run multiple unwrapping list