Banana is focused on building the machine learning infrastructure.This example goes over how to use LangChain to interact with Banana models
Copy
##Installing the langchain packages needed to use the integrationpip install -qU langchain-community
Copy
# Install the package https://docs.banana.dev/banana-docs/core-concepts/sdks/pythonpip install -qU banana-dev
Copy
# get new tokens: https://app.banana.dev/# We need three parameters to make a Banana.dev API call:# * a team api key# * the model's unique key# * the model's url slugimport os# You can get this from the main dashboard# at https://app.banana.devos.environ["BANANA_API_KEY"] = "YOUR_API_KEY"# OR# BANANA_API_KEY = getpass()
Copy
from langchain.chains import LLMChainfrom langchain_community.llms import Bananafrom langchain_core.prompts import PromptTemplate
# Both of these are found in your model's# detail page in https://app.banana.devllm = Banana(model_key="YOUR_MODEL_KEY", model_url_slug="YOUR_MODEL_URL_SLUG")
Copy
llm_chain = LLMChain(prompt=prompt, llm=llm)
Copy
question = "What NFL team won the Super Bowl in the year Justin Beiber was born?"llm_chain.run(question)