Skip to content

Forum in maintenance, we will back soon 🙂

How To Create AI To...
 
Notifications
Clear all

How To Create AI Tools Fast (Less Than 2 Minutes)

17 Posts
3 Users
4 Reactions
55 Views
 Omar
(@zimbabox)
Posts: 10
Member
Topic starter
 

Hi Hasan, I am following your Youtube short tutorial " How To Create AI Tools Fast (Less Than 2 Minutes)" you didn't mention any thing about helpers directory that I had to create with the structured_generator.py file in! also I had one issue when I run the script, according to ChatGPT I had to add this code into the structured_generator.py which some parts of the script needs to be replaced and I don't exactly to be replaced with! starting with, your_module and more...!  (check the code snap)

from your_module import structured_generator  # Import the function

# Example usage:
openai_model = "your_openai_model"
prompt_text = "your_prompt_text"
# Assuming Titles is a Pydantic model class with a 'titles' field
titles_instance = structured_generator(openai_model, prompt_text, Titles)



 
Posted : 12/09/2023 10:10 am
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@zimbabox please share your code via a public link on Github. Without viewing the entire code it is hard to help you.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 12/09/2023 7:29 pm
 Omar
(@zimbabox)
Posts: 10
Member
Topic starter
 

Hi, there is nothing to share as the code, links and all the materials exist already on Github link that Hasan provided on his website, I have just used his code to see if it will work with me or not, and it didn't work for the reason that on my error consul of the Visual Studio Code, thanks any way for your help!

 
Posted : 12/10/2023 10:45 pm
Hasan Aboul Hasan
(@admin)
Posts: 1276
Member Admin
 

Hi Friend, What is the helpers directory?

You dont need to create anything, just install the packages and run. dont change anything. 

helpers.py is a module, not a directory.

 

 

 
Posted : 12/11/2023 6:42 am
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@zimbabox okay, but your use of the code that @Hasan provided isn't correct and the pictures and detail you've given isn't enough to help you. So, please share a public link to your code if you want help. You can feel free to schedule a 1-on-1 with me if you wish using the calendar link in my signature.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 12/12/2023 5:07 pm
 Omar
(@zimbabox)
Posts: 10
Member
Topic starter
 

Thanks for your follow up on my issue. The issue is fixed now and I am into a new issue now! I am trying to implement the tutorial  "LLM Generic Function" and the code is not generating any output for some reason, I think it's outdated.

import openai import nlpcloud import cohere """ LLMs: OpenAI NlpCloud Cohere You can add your own """ 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-RNm6d9" 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 #nlpCloud Function nlp_cloud_key = "bc1dc0031" def nlp_cloud_generate(user_prompt,selected_model): client = nlpcloud.Client(selected_model, nlp_cloud_key, gpu=True, lang="en") result = client.generation( user_prompt, min_length=0, max_length=100, length_no_input=True, remove_input=True, end_sequence=None, top_p=1, temperature=0.8, top_k=50, repetition_penalty=1, length_penalty=1, do_sample=True, early_stopping=False, num_beams=1, no_repeat_ngram_size=0, num_return_sequences=1, bad_words=None, remove_end_sequence=False ) return result["generated_text"] #Cohere API cohere_api_key = "KXSfvlpAXW" def cohere_generate(user_prompt,selected_model): co = cohere.Client(cohere_api_key) # This is your trial API key response = co.generate( model=selected_model, prompt=user_prompt, max_tokens=300, temperature=0.9, k=0, stop_sequences=[], return_likelihoods='NONE') return response.generations[0].text

 
Posted : 12/14/2023 11:59 pm
 Omar
(@zimbabox)
Posts: 10
Member
Topic starter
 

Thanks for your follow up on my issue. The issue is fixed now and I am into a new issue now! I am trying to implement the tutorial  "LLM Generic Function" and the code is not generating any output for some reason, I think it's outdated.

https://github.com/almutabbil/LLM_Generic_Function/tree/main

 
Posted : 12/15/2023 12:17 am
Hasan Aboul Hasan
(@admin)
Posts: 1276
Member Admin
 

@zimbabox trying to generate with OpenAI? or another API?

any errors?

 
Posted : 12/15/2023 9:05 am
 Omar
(@zimbabox)
Posts: 10
Member
Topic starter
 

@admin Yes Hasan it is only with OpenAI and I am getting this error:

AttributeError: module 'openai' has no attribute 'chat'
 
Posted : 12/15/2023 10:52 am
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@zimbabox if you add your app.py (or whatever you called it) file to the repository I can try to help debug it.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 12/15/2023 1:52 pm
Hasan Aboul Hasan
(@admin)
Posts: 1276
Member Admin
 

@zimbabox did you update OpenAI Package to the latest?

 
Posted : 12/16/2023 2:31 pm
 Omar
(@zimbabox)
Posts: 10
Member
Topic starter
 

I am on the "Generate Ideas lesson"  and I am getting this error, why is that?: 

Please ensure the domain names can feature a combination of words and numbers, allowing for unique and memorable options. Emphasize creating domain names that are engaging, relevant, and aligned with the target audience's interests. Also, consider how each domain name could benefit and resonate with the target audience. Remember to aim for creativity and flexibility in your domain name selections.
    open_ai_response = llm.llm_generate_text(prompt, "service", "command")
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "d:\Users\alhak\Downloads\Google-suggestions-api\llm.py", line 34, in llm_generate_text
    raise ValueError(f"Invalid service: {service}")
ValueError: Invalid service: service
 
Posted : 12/19/2023 12:03 am
SSAdvisor
(@ssadvisor)
Posts: 1139
Noble Member
 

@zimbabox you've given "service" as the service which isn't expected so you get an exception.  If you review the code in llm.py you'll see the filter for the expected service, give the function one of those. While you're at it "command" probably isn't what you want either.

Regards,
Earnie Boyd, CEO
Seasoned Solutions Advisor LLC
Schedule 1-on-1 help
Join me on Slack

 
Posted : 12/19/2023 3:21 pm
Hasan Aboul Hasan
(@admin)
Posts: 1276
Member Admin
 

@zimbabox the service must be one of the defined ones in the function. please review the "llm_generate_text" function.

 
Posted : 12/19/2023 4:17 pm
 Omar
(@zimbabox)
Posts: 10
Member
Topic starter
 

@admin So if one should be called service, what should I call then the other two? I couldn't find your original llm.py file to compare the code with mine!

 
Posted : 12/19/2023 4:59 pm
Page 1 / 2
Share:
[the_ad_group id="312"]