2023-08-13 06:28:24 +03:00
|
|
|
from g4f import Provider, models
|
2023-07-23 04:20:03 +03:00
|
|
|
from langchain import PromptTemplate
|
2023-08-13 06:28:24 +03:00
|
|
|
from langchain.llms.base import LLM
|
2023-07-23 04:20:03 +03:00
|
|
|
|
|
|
|
from langchain_g4f import G4FLLM
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
template = "What color is the {fruit}?"
|
|
|
|
prompt_template = PromptTemplate(template=template, input_variables=["fruit"])
|
|
|
|
|
|
|
|
llm: LLM = G4FLLM(
|
2023-08-13 06:28:24 +03:00
|
|
|
model=models.gpt_35_turbo,
|
2023-07-23 04:20:03 +03:00
|
|
|
provider=Provider.Aichat,
|
|
|
|
)
|
|
|
|
|
|
|
|
res = llm(prompt_template.format(fruit="apple"))
|
|
|
|
print(res)
|
|
|
|
# The color of an apple can vary, but it is typically red, green, or yellow.
|
|
|
|
|
|
|
|
res = llm(prompt_template.format(fruit="lemon"))
|
|
|
|
print(res)
|
|
|
|
# The color of a lemon is typically yellow.
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|