Spaces:
Sleeping
Sleeping
| #!/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() |