SmartCaseAI / use_case_generation.py
Hyma7's picture
Update use_case_generation.py
fc8c1ae verified
import openai
import os
# Set up your OpenAI API key
openai.api_key = os.getenv("22ec84421ec24230a3638d1b51e3a7dc")
def generate_use_cases(company_info):
use_cases = []
references = ["McKinsey AI Report", "Deloitte Industry Insights"]
# Generate suggestions based on company focus areas
if "customer experience" in company_info["focus_areas"]:
suggestion = get_openai_response("Suggest a GenAI-driven chatbot for enhanced customer support.")
use_cases.append(suggestion)
if "operations" in company_info["focus_areas"]:
suggestion = get_openai_response("Propose using predictive maintenance models to streamline operations.")
use_cases.append(suggestion)
if "supply chain" in company_info["focus_areas"]:
suggestion = get_openai_response("Describe how real-time analytics could improve supply chain transparency.")
use_cases.append(suggestion)
return {"use_cases": use_cases, "references": references}
def get_openai_response(prompt, model="gpt-4"):
try:
response = openai.ChatCompletion.create(
model=model,
messages=[{"role": "user", "content": prompt}]
)
return response['choices'][0]['message']['content']
except Exception as e:
print(f"Error generating response from OpenAI: {e}")
return "Could not generate use case."