Instructions to use Athipan01/Got with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Adapters
How to use Athipan01/Got with Adapters:
from adapters import AutoAdapterModel model = AutoAdapterModel.from_pretrained("undefined") model.load_adapter("Athipan01/Got", set_active=True) - Notebooks
- Google Colab
- Kaggle
| from transformers import pipeline | |
| class SimpleAssistant: | |
| def __init__(self, model_name="facebook/bart-large-cnn"): | |
| """ | |
| สร้าง AI ผู้ช่วยอย่างง่ายโดยใช้โมเดลภาษาที่กำหนด | |
| """ | |
| self.model_name = model_name | |
| self.nlp = pipeline("text-generation", model=self.model_name) | |
| def get_response(self, user_input, max_length=50, num_return_sequences=1): | |
| """ | |
| สร้างการตอบสนองต่ออินพุตของผู้ใช้ | |
| """ | |
| try: | |
| response = self.nlp(user_input, max_length=max_length, num_return_sequences=num_return_sequences) | |
| return response[0]['generated_text'] | |
| except Exception as e: | |
| print(f"เกิดข้อผิดพลาด: {e}") | |
| return "ขออภัย ฉันไม่เข้าใจ" | |
| # ตัวอย่างการใช้งาน | |
| if __name__ == "__main__": | |
| assistant = SimpleAssistant() | |
| print("ผู้ช่วยพร้อมใช้งานแล้ว! พิมพ์ 'ออก' เพื่อจบการสนทนา") | |
| while True: | |
| user_input = input("คุณ: ") | |
| if user_input.lower() == "ออก": | |
| print("ลาก่อน!") | |
| break | |
| response = assistant.get_response(user_input) | |
| print("ผู้ช่วย: " + response) |