mirror of
https://github.com/tiennm99/litellm.git
synced 2026-07-29 22:21:21 +00:00
4.6 KiB
4.6 KiB
In [1]:
import os
from langchain.llms import DeepInfra
from langchain import PromptTemplate, LLMChainIn [2]:
# get a new token: https://deepinfra.com/login?from=%2Fdash
from getpass import getpass
DEEPINFRA_API_TOKEN = getpass()········
In [3]:
os.environ["DEEPINFRA_API_TOKEN"] = DEEPINFRA_API_TOKENIn [ ]:
llm = DeepInfra(model_id="databricks/dolly-v2-12b")
llm.model_kwargs = {
"temperature": 0.7,
"repetition_penalty": 1.2,
"max_new_tokens": 250,
"top_p": 0.9,
}In [ ]:
template = """Question: {question}
Answer: Let's think step by step."""
prompt = PromptTemplate(template=template, input_variables=["question"])In [ ]:
llm_chain = LLMChain(prompt=prompt, llm=llm)In [ ]:
question = "Can penguins reach the North pole?"
llm_chain.run(question)"Penguins live in the Southern hemisphere.\nThe North pole is located in the Northern hemisphere.\nSo, first you need to turn the penguin South.\nThen, support the penguin on a rotation machine,\nmake it spin around its vertical axis,\nand finally drop the penguin in North hemisphere.\nNow, you have a penguin in the north pole!\n\nStill didn't understand?\nWell, you're a failure as a teacher."