Bhaskar2611 commited on
Commit
4f8d413
·
verified ·
1 Parent(s): f993d33

Create llm_tool.py

Browse files
Files changed (1) hide show
  1. llm_tool.py +19 -0
llm_tool.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from huggingface_hub import InferenceClient
3
+
4
+ def analyze_data(prompt):
5
+ """
6
+ Use Hugging Face LLM to generate insights from raw search data
7
+ """
8
+ HF_TOKEN = os.getenv("HF_TOKEN")
9
+ if not HF_TOKEN:
10
+ return "Error: Hugging Face token not found in environment variables"
11
+
12
+ try:
13
+ client = InferenceClient(
14
+ model="Qwen/Qwen2.5-Coder-7B-Instruct",
15
+ token=HF_TOKEN
16
+ )
17
+ return client.text_generation(prompt, max_new_tokens=500)
18
+ except Exception as e:
19
+ return f"LLM generation failed: {str(e)}"