Creates and invokes an LLM chain using the prompt template and the history.
(prompt_template: str, llm, history: str)
| 71 | |
| 72 | |
| 73 | def create_llm_chain(prompt_template: str, llm, history: str) -> str: |
| 74 | """ |
| 75 | Creates and invokes an LLM chain using the prompt template and the history. |
| 76 | """ |
| 77 | prompt = PromptTemplate.from_template(prompt_template) |
| 78 | llm_chain = prompt | llm | StrOutputParser() |
| 79 | inputs = {"history": history} |
| 80 | generation = llm_chain.invoke(inputs) |
| 81 | |
| 82 | return generation |
| 83 | |
| 84 | def create_llm_chain_google(prompt_template: str, llm, history: Optional[str] = None) -> str: |
| 85 | url = "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent" |
no outgoing calls
no test coverage detected