diff options
author | Ben Sima <ben@bsima.me> | 2022-12-16 09:40:27 -0500 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2022-12-16 09:40:27 -0500 |
commit | 11e480c4b13808f12bc3f5db2765cebebf1aaf46 (patch) | |
tree | b04e671775018f864ce78ddec5abd7557739a7b1 | |
parent | 6edd44ebc073c2bc5e299a481c4a8586f5e0158a (diff) |
Stub ava chatbot
-rw-r--r-- | Biz/Bild.nix | 1 | ||||
-rwxr-xr-x | ava.py | 50 |
2 files changed, 51 insertions, 0 deletions
diff --git a/Biz/Bild.nix b/Biz/Bild.nix index a49f10e..47c0ecb 100644 --- a/Biz/Bild.nix +++ b/Biz/Bild.nix @@ -148,6 +148,7 @@ rec { lolcat nixops ormolu + (python3.withPackages(p: with p; [transformers pytorch])) shellcheck wemux ]; @@ -0,0 +1,50 @@ +#!/usr/bin/env python +import transformers import AutoModelWithLMHead, AutoTokenizer, TextGenerator +# import sleekxmpp + +model_name = "gpt-neox-20b" + +model = AutoModelWithLMHead.from_pretrained(model_name) +tokenizer = AutoTokenizer.from_pretrained(model_name) +generator = TextGenerator(model=model, tokenizer=tokenizer) + +def generate_response(input_text): + response = model.generate( + input_ids=input_text, + max_length=1024, + temperature=0.7, + ) + return response + +# Get user input and generate a response +user_input = input("User: ") +response = generate_response(user_input) +print("Bot: ", response) + +""" +# Set up the XMPP client +client = sleekxmpp.ClientXMPP( + "ava@simatime.com", + "test" +) +client.connect() +client.process(block=True) + +# Define a function that takes in a user's input and returns a response +def generate_response(input_text): + # You would use your language model to generate a response here + response = "This is a response to the user's input: " + input_text + return response + +# Handle incoming messages +@client.add_event_handler("message") +def handle_message(message): + # Get the user's input + user_input = message["body"] + + # Generate a response + response = generate_response(user_input) + + # Send the response to the user + message.reply(response).send() +""" |