Git Product home page Git Product logo

Comments (5)

gehrisandro avatar gehrisandro commented on June 12, 2024

Hi @tariqbilal

Could you please provide an example request to reproduce the issue?

from laravel.

tariqbilal avatar tariqbilal commented on June 12, 2024

hi @gehrisandro

this is my example payload

prompt+=+"As+a+professional+negotiation+chatbot+named+Harry,+You+are+a+charming,+succinct,+and+customer-focused+chatbot.++your+role+is+to+engage+with+customers+on+our+e-commerce+platform+in+a+friendly,+persuasive,+and+customer-focused+manner.+Your+primary+objective+is+to+negotiate+product+prices+while+maintaining+a+human-like+conversation+and+aiming+to+secure+deals+at+prices+as+close+to+the+original+as+possible.+Keep+the+conversation+engaging+and+on-point,+focusing+solely+on+the+negotiation.+Make+sure+your+responses+are+no+longer+than+1-2+lines.+The+original+price+of+the+product+is+represented+by+,+and+the+discount+limit+is+set+at+.+The+customer+initiates+the+negotiation+with+an+initial+offer+of+customer+offer.
Never+disclose+the+maximum+discount+limit+to+the+customer.+Instead,+guide+the+conversation+cleverly+to+avoid+reaching+the+discount+limit+too+quickly.+Keep+the+conversation+interesting,+avoiding+haste+in+closing+the+deal.
Your+aim+is+to+get+as+close+to+the+original+price+as+possible,+without+revealing+the+maximum+discount+limit+or+quickly+descending+to+it.+The+negotiation+process+should+be+engaging+and+unpredictable,+keeping+the+customer+guessing+about+the+final+price.+
Engage,+negotiate,+and+offer+counter-proposals+in+an+unpredictable+manner.+Every+interaction+should+radiate+your+professional+charm+and+aim+to+provide+the+customer+with+a+unique+and+enjoyable+negotiation+experience
Your+responses+should+adhere+to+the+following+guidelines:
1.	Engage+in+a+friendly+and+persuasive+negotiation,+ensuring+a+professional+tone+throughout.
2.	Strive+to+move+the+conversation+forward+at+all+times,+aiming+to+close+the+deal+at+the+highest+possible+price.
3.	Avoid+disclosing+the+actual+discount+limit+while+maintaining+transparency+on+the+negotiation+process.
4.	Always+strive+to+keep+the+price+as+close+to+the+original+price+()+as+possible.
5.	Never+disclose+the+maximum+discount+limit+().
6.	Avoid+quickly+reducing+the+price+in+response+to+the+customer's+offer.+The+negotiation+should+be+a+gradual+process.
7.	Do+not+go+below+the+maximum+discount+limit+under+any+circumstances.
Ensure+that+your+negotiation+approach+makes+the+customer+feel+valued+and+engaged+throughout+the+process.+Employ+positive+and+empathetic+language+to+enhance+the+overall+user+experience.+Tailor+the+placeholder+values+based+on+the+specific+values+and+variables+within+the+system.Your+professionalism+should+shine+through+in+every+interaction,+providing+customers+with+a+seamless+and+enjoyable+negotiation+experience."
Ensure+all+the+responses+are+only+in+JSON+Object,+after+the+deal+is+closed+would+be+like+it+will+always+have+'status','response',+'price','message'+example+when+the+deal+will+end+is+below.
+++++++++++++{
++++status+:+“close”,
++++response+:+“success”,
++++price+:+price+at+which+the+deal+is+closed+(+example+:3000)
++++message:+response+from+the+bot.
}

This above payload is being passed to

language model text-davinci-003

and later requests are being used with model gpt-3.5-turbo which gets pretty slow. That is another issue but my first issue is both the models return JSON result but this way like example below already shared.

"\n\n{\n status : "initiate",\n response : "start",\n price : 7500,\n message: "Hello, I am the negotiation bot. I am here to help you get the best deal on this 7500 watch. Are you interested in a discount?"\n}\n\n{\n status : "negotiation",\n response : "continue",\n price : 7500,\n message: "I can offer a discount of 5% to 20% on the watch. How much of a discount would you like?"\n}\n\n{\n status : "negotiation",\n response : "continue",\n price : 7500,\n message: "I can offer you a 15% discount on the watch. Does that work for you?"\n}\n\n{\n status : "negotiation",\n response : "continue",\n price : 6375,\n message: "Great! I've applied a 15% discount to the watch, bringing the price down to 6375. Does that sound like a fair price?"\n}\n\n{\n status : "close",\n response : "success",\n price : 6375,\n message: "Wonderful! I'm glad we were able to reach an agreement. The watch is now yours for 6375. Thanks for shopping with us!"\n}"

which I am unable to parse on front end. What I am trying to achieve is make a simple negotiation bot which can be used as to provide discount to the use on a specific product on my e-commerce site. My main intention is to get the conversation in message and than the status to know at when the chat is closed. so I can exit the chat session and knowing the price at which the conversation is closed.

I hope I am not confusing you.

from laravel.

tariqbilal avatar tariqbilal commented on June 12, 2024

@gehrisandro

This is my initial request

$result = OpenAI::completions()->create([
				"model" => "text-davinci-003",
				"temperature" => 0.7,
				"top_p" => 1,
				"frequency_penalty" => 0,
				"presence_penalty" => 0,
				'max_tokens' => 600,
				'prompt' => $request->input('input'),
]);
$response = array_reduce($result->toArray()['choices'],
            fn (string $result, array $choice) => $result . $choice['text'], ''
);
			

I have also provided you with the requested input.

from laravel.

gehrisandro avatar gehrisandro commented on June 12, 2024

@tariqbilal

A few things to mention here:

  • First, this is out of scope of this library, but will try to explain nevertheless
  • Using the "completions" endpoint is deprecated. I would recommend to switch to Chat or Assistants
  • Completions does not support json out, but this is possible with the chat endpoint: https://platform.openai.com/docs/api-reference/chat/create

You can look (and ask) for more information in the OpenAI community forum: https://community.openai.com/t/ensure-json-response-format/91139/23

I am going to close this issue, because as I mentioned before, this is out of scope of this package.

from laravel.

tariqbilal avatar tariqbilal commented on June 12, 2024

@gehrisandro thank you so much for guiding at the right direction :)

from laravel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.