Using the OpenAI Chat API from Servoy

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

Using the OpenAI Chat API from Servoy

Postby ProRM » Wed May 24, 2023 7:32 pm

Hi,

Has anyone used the OpenAI ChatGPT API from Servoy?

We are thinking of adding to an ERP the possibility to ask for some data just in a promp or speaking, something like "How long has it been since we sold to so-and-so?" or "How much does the Turkish electricity company owe us?"

Regards,
User avatar
ProRM
 
Posts: 107
Joined: Thu Sep 18, 2008 10:24 pm
Location: Uruguay

Re: Using the OpenAI Chat API from Servoy

Postby JuanMartin » Wed May 24, 2023 8:10 pm

Hi

+1
Juan Antonio Martín Pinilla
Servoy 2023.3.3 - PostgreSql 14
[email protected]
User avatar
JuanMartin
 
Posts: 170
Joined: Tue Nov 25, 2008 9:20 pm
Location: Tenerife - Spain

Re: Using the OpenAI Chat API from Servoy

Postby sean » Wed May 24, 2023 8:17 pm

Hi Juan,

I'm actively looking into this, as I'm sure many others are. I haven't spent any using their API directly.

Instead, exploring prompts and what the model can learn when you provide it certain texts.
For example, it seems to understand the schema of a database, expressed as SQL. In my playtime, I have exported the northwinds example database schema as SQL and fed it in with various natural language prompts. (see image below)

What's compelling about this, is that I didn't need to tell it about orders and order details or specific column names. I only asked it about the quantity of a product that was sold to a customer in France. By the way, I ran it and it works - Pretty cool!

What's next?...well I'm not stopping anybody from using Servoy's HTTP plugin from trying this out today in an application ;-) ...but maybe we can think of some integration paths.

Please tell us more about your ideas!

Saludos,
Sean

chat-to-sql.PNG
chat-to-sql.PNG (57.58 KiB) Viewed 3934 times
Software Engineer
Servoy USA
sean
 
Posts: 380
Joined: Mon May 21, 2007 6:26 pm
Location: USA

Re: Using the OpenAI Chat API from Servoy

Postby steve1376656734 » Wed May 24, 2023 9:30 pm

We have written an NG2 service that uses the API and this works quite well. We encountered one issue where the API returns a JSON object with a property called "model" and Servoy did not like that as a property name in the .spec file (SVY-18026.

The service utilises the ChatGPT3.5 language model and this will know nothing about your own data (unless you feed it in) but it is possible that you could create what you need using an open source project such as https://github.com/pashpashpash/vault-ai which allows you to use the OpenAI API interface to query your own data in a Pinecone Vector Database but this relies on your data being in a document type format.

If you use the API directly then be aware that any data you send it can become publicly available as the language model can use anything it's given as further training (see https://mashable.com/article/samsung-ch ... ak-details)!

This is a fast evolving arena and I look forward to seeing what happens over the next few months.
Steve
SAN Developer
There are 10 types of people in the world - those that understand binary and those that don't
steve1376656734
 
Posts: 338
Joined: Fri Aug 16, 2013 2:38 pm
Location: Ashford, UK

Re: Using the OpenAI Chat API from Servoy

Postby ProRM » Wed May 24, 2023 10:41 pm

Hola Sean and great Steve,

What about documenting each form telling what is it for and load the AI with that?
User avatar
ProRM
 
Posts: 107
Joined: Thu Sep 18, 2008 10:24 pm
Location: Uruguay

Re: Using the OpenAI Chat API from Servoy

Postby steve1376656734 » Wed May 24, 2023 10:57 pm

My initial thoughts would be to load the AI with your DB structure in a similar way to how Sean has explained it. You could then train it so that it accepts a plain text enquiry from the user and the response would be the SQL required to get the desired result. That could then be loaded into a Servoy query and the data displayed to the user.

That way the AI is only exposed to the data structure and your actual data remains private. Additionally, if the AI was to have the data to return the result, then it would need to be constantly updated with the current data.
Steve
SAN Developer
There are 10 types of people in the world - those that understand binary and those that don't
steve1376656734
 
Posts: 338
Joined: Fri Aug 16, 2013 2:38 pm
Location: Ashford, UK

Re: Using the OpenAI Chat API from Servoy

Postby ProRM » Wed May 24, 2023 11:14 pm

This proposes me ChatGPT:

To allow users to enter their chatGPT-style requirements in your ERP software and interpret what they want to know, you can follow these steps:

1. Implement a chat interface: Create an interface where users can enter their requirements in a chat-like manner. This can include a text box where they can type their query.

2. Use natural language processing (NLP) technology: To interpret the user's requirement, you'll need to utilize natural language processing techniques. You can use available NLP libraries or services such as NLTK, spaCy, or OpenAI's Natural Language Processing API.

3. Train a model for the specific task: You can train a model using machine learning techniques, particularly language models like GPT, to interpret and respond to specific questions. To train a model, you'll need a labeled dataset that includes questions similar to what users might ask.

4. Establish patterns and rules: In addition to the language model, you can set patterns and rules to identify certain common types of questions. For example, if the user asks, "How much does customer X owe?" you can establish a rule that recognizes that question structure and extracts relevant information like the customer's name.

5. Integrate interpretation and response into your ERP: Once you've interpreted the user's question and extracted the relevant information, you can use that information to query your ERP's database and retrieve the appropriate response. For example, in the case of "How much does customer X owe?" you could look up customer X's transaction history and calculate the outstanding balance.

6. Present the response to the user: Finally, display the obtained response to the user in your ERP software's chat interface. You can use a conversation-like format to present the response clearly and comprehensibly.

Remember that developing a natural language understanding system can be complex and requires continuous testing and refinement. It's important to consider different scenarios and ensure that the system can handle variations in questions and accurately understand the user's intentions.
User avatar
ProRM
 
Posts: 107
Joined: Thu Sep 18, 2008 10:24 pm
Location: Uruguay


Return to How To

Who is online

Users browsing this forum: No registered users and 1 guest