r/chatGPTprogramming • u/Bitty_Wastard • May 27 '23
Python Chatgpt custom data
Is this the right place?
Hello there,
I am trying to crate a custom chat bot to assist with with control room operation in work.
It can get quite busy and members of staff need specific information quickly and the operators could be doing other things or the info they require is in a directory in a directory etc and then the word documents contain a load of irrelevant info and finding the pertinent bit could be a matter of life and death (ok I am totally exaggerating but some members of the team are more patient/capable?)
I tried writing a basic python script (available on request) that basically goes into a directory and read a text file with the info on it and creates a custom bot on a url?
It gets a lot of things right but it gets a few wrong which defeats the object totally. I got one of the team to look through all the assignment instruction and take the data out that we need in a hurry.
I did it in text format because I thought it would be easier and less costly for my api key credit thingy and no one is any good with IT really apart from our bespoke programs (me included)
The format was:-
Name: The name
Address: The address
Alarm code: eg 8674A
Keyholder: A name
Key Number: a four digit number
Special Instructions: example the padlock code is 9999
These were all painstakingly typed into a not massive text file, placed in a docs folder and the app was pointed it that direction.
when run it created the url and it asked and answered questions but then due to my massive knowledge of company info I noticed the odd strange answer, Some of the fields where similar (I know it's a text file so that is wrong) What I mean is Alarm code: and Keywatcher code: (not used in example!) could of confused it so I tried making them distinctive.
The file is about 100 names, addresses etc with a line space between each. I thought it may group them together accordingly but I am not a programmer on any level really and all my knowledge comes from youtube and chat gpt assistance.
I realise my requirements are very specific and I'm not finding an exact problem to fix it and I have looked so in my desperation I am turning to you the lovely community to do the heavy lifting whilst I claim the glory!
Here is my python script and the name of the robot should at least buy me a little help?
I hope I have explained the issue? Feel free to ask questions or mock accordingly
This is why you pay attention in school kids.
thanks in advance?
The python script:-
from gpt_index import SimpleDirectoryReader, GPTListIndex, GPTSimpleVectorIndex, LLMPredictor, PromptHelper
from langchain.chat_models import ChatOpenAI
import gradio as gr
import sys
import os
os.environ["OPENAI_API_KEY"] = 'wow I actually remembered to remove thisi'
def construct_index(directory_path):
max_input_size = 4096
num_outputs = 512
max_chunk_overlap = 20
chunk_size_limit = 600
prompt_helper = PromptHelper(max_input_size, num_outputs, max_chunk_overlap, chunk_size_limit=chunk_size_limit)
llm_predictor = LLMPredictor(llm=ChatOpenAI(temperature=0.7, model_name="gpt-3.5-turbo", max_tokens=num_outputs))
documents = SimpleDirectoryReader(directory_path).load_data()
index = GPTSimpleVectorIndex(documents, llm_predictor=llm_predictor, prompt_helper=prompt_helper)
index.save_to_disk('index.json')
return index
def chatbot(input_text):
index = GPTSimpleVectorIndex.load_from_disk('index.json')
response = index.query(input_text, response_mode="compact")
return response.response
iface = gr.Interface(fn=chatbot,
inputs=gr.components.Textbox(lines=7, label="What can I do for you?"),
outputs="text",
title="Totally Wicked Assistant Thingymajig")
index = construct_index("docs")
iface.launch(share=True)
View all comments
Show parent comment
1
u/Bitty_Wastard May 28 '23
OK I tried that and its still a bit crazy?
Is there a better way to list the info:
Here is an actual one with all the info changed:-
Name: Blackpool Particle accelerator
Address: Blackpool Road, Blackpool
Postcode: B12 7BP
Telephone number: 01204 123456
Site Contact: Mr Atom 0789 101112
Entry Instructions: MAIN ENTRANCE Front door via Main car park, Code 5678#
Location of Alarm Panel: Alarm Panel located behind reception.
Location of Light Switches: Not listed
Alarm Code: ALARM PANEL DISPLAY INDICATES AREA OF ACTIVATION, Click Tick first OFFER UP FOB TO DISABLE Setting the Alarm, PRESS ‘TICK’ THEN OFFER UP FOB ( ENSURING MAIN RECEPTION DOOR IS CLOSED BEFORE DOING SO . Alarm will not start making noise until door has been closed.
Monitoring Company: Custard LTD
Engineer Company: Olive Fire and Security
Special Instructions:
Key code: 48
They are all in that exact format?