Forum in maintenance, we will back soon π
Notifications
Clear all
How To Create AI Tools Fast (Less Than 2 Minutes)
Page 2 / 2
Prev
Share your Prompts & Tests
17
Posts
3
Users
4
Reactions
55
Views
'''From File: llm.py''' def llm_generate_text(prompt, service, model): if service == "OpenAI": generated_text = openai_generate(prompt, model) elif service == "NlpCloud": generated_text = nlp_cloud_generate(prompt, model) elif service == "Cohere": generated_text = cohere_generate(prompt, model) return generated_text # Open AI Function openai.api_key = "sk-XXX" def openai_generate(user_prompt, selected_model): completion = openai.chat.completions.create( model=selected_model, messages=[{"role": "user", "content": user_prompt}] ) return completion.choices[0].message.content
Β Then you use one of "OpenAI", "NlpCloud" or "Cohere" for the service parameter. For the model you need one of the ones mentioned in the documentation at https://platform.openai.com/docs/guides/text-generation .
'''file: app.py''' import llm prompt = "What is AI prompt engineering?" result = llm.llm_generate_text(prompt, "OpenAI", "gpt-3.5-turbo") print result.
Β You can find the course codes at https://github.com/hassancs91/PE-Course-codes
This post was modified 1 year ago by SSAdvisor
Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack
Posted : 12/20/2023 7:00 pm
Omar and Hasan Aboul Hasan reacted
@zimbabox why you can't find the code?Β
here it is:
PE-Course-codes/llm.py at main Β· hassancs91/PE-Course-codes (github.com)
Posted : 12/20/2023 7:13 pm
Omar reacted
Page 2 / 2
Prev
Forum Jump:
Related Topics
-
I am getting 400 Bad Request when testing API using Thunder Client
5 months ago
-
Connect Python With OpenAI API
1 year ago
Forum Information
Our newest member: Shaik Abdul Raheem
Latest Post: Affiliate tool.
Forum Icons:
Forum contains no unread posts
Forum contains unread posts
Topic Icons:
Not Replied
Replied
Active
Hot
Sticky
Unapproved
Solved
Private
Closed
[the_ad_group id="312"]