Spaces:
Sleeping
Sleeping
File size: 2,059 Bytes
2fe12d9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
#!/usr/bin/env python3
"""
Dwrko-M1.0 Usage Examples
How others can use your Claude-like AI assistant
"""
import requests
import json
# Method 1: Using HuggingFace Spaces API
def use_dwrko_via_api(prompt):
"""Use Dwrko-M1.0 via HuggingFace Spaces API"""
api_url = "https://dwrkotech-dwrko-m1-0.hf.space/api/predict"
payload = {
"data": [prompt]
}
response = requests.post(api_url, json=payload)
return response.json()
# Method 2: Direct Integration
def use_dwrko_direct():
"""Direct integration example"""
from transformers import AutoTokenizer, AutoModelForCausalLM
# Load your trained Dwrko-M1.0
tokenizer = AutoTokenizer.from_pretrained("dwrkotech/Dwrko-M1.0")
model = AutoModelForCausalLM.from_pretrained("dwrkotech/Dwrko-M1.0")
# Generate response
prompt = "Write a Python function to calculate factorial"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_length=200)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
return response
# Method 3: Gradio Interface Integration
def create_custom_interface():
"""Create custom interface using Dwrko-M1.0"""
import gradio as gr
def dwrko_chat(message):
# Call your Dwrko-M1.0 API
response = use_dwrko_via_api(message)
return response
# Create custom interface
interface = gr.Interface(
fn=dwrko_chat,
inputs="text",
outputs="text",
title="My Custom Dwrko-M1.0 Assistant",
description="Powered by Dwrko-M1.0"
)
return interface
# Example usage
if __name__ == "__main__":
# Test API method
result = use_dwrko_via_api("Explain what is machine learning")
print("API Response:", result)
# Test direct method (requires model download)
# result = use_dwrko_direct()
# print("Direct Response:", result)
# Launch custom interface
# interface = create_custom_interface()
# interface.launch() |