KalooAI commited on
Commit
0061aa0
·
verified ·
1 Parent(s): fa43a5a

Update app.py

Browse files

added : import os
import uuid
from langchain_huggingface import HuggingFaceEndpoint

Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -5,6 +5,10 @@
5
  # from ibm_watsonx_ai import Credentials
6
  # from langchain_ibm import WatsonxLLM, WatsonxEmbeddings
7
 
 
 
 
 
8
  from langchain_text_splitters import RecursiveCharacterTextSplitter
9
  from langchain_community.vectorstores import Chroma
10
  from langchain_community.document_loaders import PyPDFLoader
@@ -38,13 +42,16 @@ warnings.filterwarnings('ignore')
38
  # return watsonx_llm
39
 
40
  def get_llm():
41
- def _llm(prompt: str) -> str:
42
- return client.text_generation(
43
- prompt,
44
- max_new_tokens=256,
45
- temperature=0.5
46
- )
47
- return _llm
 
 
 
48
 
49
  ## Document loader
50
  def document_loader(file):
 
5
  # from ibm_watsonx_ai import Credentials
6
  # from langchain_ibm import WatsonxLLM, WatsonxEmbeddings
7
 
8
+ import os
9
+ import uuid
10
+ from langchain_huggingface import HuggingFaceEndpoint
11
+
12
  from langchain_text_splitters import RecursiveCharacterTextSplitter
13
  from langchain_community.vectorstores import Chroma
14
  from langchain_community.document_loaders import PyPDFLoader
 
42
  # return watsonx_llm
43
 
44
  def get_llm():
45
+ # This uses Hugging Face's free Inference API to run the model
46
+ # You don't need Ollama for this!
47
+ llm = HuggingFaceEndpoint(
48
+ repo_id="ibm-granite/granite-3.1-8b-instruct", # Use the latest available on API
49
+ task="text-generation",
50
+ max_new_tokens=512,
51
+ temperature=0.1,
52
+ huggingfacehub_api_token="YOUR_HF_TOKEN_HERE" # Get this from settings
53
+ )
54
+ return llm
55
 
56
  ## Document loader
57
  def document_loader(file):