Text Generation
Transformers
English
qwen2
code-generation
python
fine-tuning
Qwen
tools
agent-framework
multi-agent
conversational
Eval Results (legacy)
Instructions to use my-ai-stack/Stack-2-9-finetuned with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use my-ai-stack/Stack-2-9-finetuned with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="my-ai-stack/Stack-2-9-finetuned") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("my-ai-stack/Stack-2-9-finetuned") model = AutoModelForCausalLM.from_pretrained("my-ai-stack/Stack-2-9-finetuned") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use my-ai-stack/Stack-2-9-finetuned with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "my-ai-stack/Stack-2-9-finetuned" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "my-ai-stack/Stack-2-9-finetuned", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/my-ai-stack/Stack-2-9-finetuned
- SGLang
How to use my-ai-stack/Stack-2-9-finetuned with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "my-ai-stack/Stack-2-9-finetuned" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "my-ai-stack/Stack-2-9-finetuned", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "my-ai-stack/Stack-2-9-finetuned" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "my-ai-stack/Stack-2-9-finetuned", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use my-ai-stack/Stack-2-9-finetuned with Docker Model Runner:
docker model run hf.co/my-ai-stack/Stack-2-9-finetuned
walidsobhie-code commited on
Commit ·
35799ef
1
Parent(s): 3c29912
Fix search with DuckDuckGo API (proper JSON parsing)
Browse files
chat.py
CHANGED
|
@@ -30,14 +30,24 @@ print(f"Settings: max_tokens={MAX_TOKENS}, temperature={TEMPERATURE}, top_p={TOP
|
|
| 30 |
print("Commands: search:<query> - search the web, quit/exit - stop\n")
|
| 31 |
|
| 32 |
def web_search(query, count=5):
|
| 33 |
-
"""Search the web using DuckDuckGo
|
| 34 |
try:
|
| 35 |
-
|
|
|
|
|
|
|
| 36 |
headers = {"User-Agent": "Mozilla/5.0 (compatible; Stack29Bot/1.0)"}
|
| 37 |
resp = requests.get(url, headers=headers, timeout=10)
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
except Exception as e:
|
| 42 |
return {"success": False, "error": str(e)}
|
| 43 |
|
|
@@ -56,8 +66,9 @@ while True:
|
|
| 56 |
print("🔍 Searching...")
|
| 57 |
result = web_search(query)
|
| 58 |
if result["success"]:
|
| 59 |
-
print(f"✅
|
| 60 |
-
|
|
|
|
| 61 |
else:
|
| 62 |
print(f"❌ Search failed: {result['error']}")
|
| 63 |
continue
|
|
|
|
| 30 |
print("Commands: search:<query> - search the web, quit/exit - stop\n")
|
| 31 |
|
| 32 |
def web_search(query, count=5):
|
| 33 |
+
"""Search the web using DuckDuckGo API"""
|
| 34 |
try:
|
| 35 |
+
import urllib.parse
|
| 36 |
+
encoded_q = urllib.parse.quote(query)
|
| 37 |
+
url = f"https://api.duckduckgo.com/?q={encoded_q}&format=json&no_redirect=1"
|
| 38 |
headers = {"User-Agent": "Mozilla/5.0 (compatible; Stack29Bot/1.0)"}
|
| 39 |
resp = requests.get(url, headers=headers, timeout=10)
|
| 40 |
+
data = resp.json()
|
| 41 |
+
|
| 42 |
+
results = []
|
| 43 |
+
if "RelatedTopics" in data:
|
| 44 |
+
for item in data["RelatedTopics"][:count]:
|
| 45 |
+
if "Text" in item:
|
| 46 |
+
results.append(item["Text"][:200])
|
| 47 |
+
|
| 48 |
+
if results:
|
| 49 |
+
return {"success": True, "results": results, "query": query}
|
| 50 |
+
return {"success": False, "error": "No results found"}
|
| 51 |
except Exception as e:
|
| 52 |
return {"success": False, "error": str(e)}
|
| 53 |
|
|
|
|
| 66 |
print("🔍 Searching...")
|
| 67 |
result = web_search(query)
|
| 68 |
if result["success"]:
|
| 69 |
+
print(f"✅ Results for '{result['query']}':\n")
|
| 70 |
+
for i, r in enumerate(result["results"], 1):
|
| 71 |
+
print(f" {i}. {r}")
|
| 72 |
else:
|
| 73 |
print(f"❌ Search failed: {result['error']}")
|
| 74 |
continue
|