Spaces:
Sleeping
Sleeping
changes
Browse files- DataSetSample.xlsx +0 -0
- app.py +28 -2
DataSetSample.xlsx
CHANGED
Binary files a/DataSetSample.xlsx and b/DataSetSample.xlsx differ
|
|
app.py
CHANGED
@@ -17,9 +17,17 @@ import requests
|
|
17 |
import io
|
18 |
from sklearn.preprocessing import StandardScaler
|
19 |
from collections import defaultdict
|
20 |
-
|
|
|
|
|
21 |
warnings.filterwarnings('ignore')
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
# Set up logging
|
24 |
logging.basicConfig(level=logging.INFO)
|
25 |
logger = logging.getLogger(__name__)
|
@@ -700,4 +708,22 @@ async def get_financial_recommendations(customer_id: str):
|
|
700 |
raise HTTPException(
|
701 |
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
702 |
detail=f"Error processing request: {str(e)}"
|
703 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
import io
|
18 |
from sklearn.preprocessing import StandardScaler
|
19 |
from collections import defaultdict
|
20 |
+
from dotenv import load_dotenv
|
21 |
+
load_dotenv() # load all the environment variables
|
22 |
+
from openai import OpenAI
|
23 |
warnings.filterwarnings('ignore')
|
24 |
|
25 |
+
client = OpenAI(
|
26 |
+
base_url = "https://integrate.api.nvidia.com/v1",
|
27 |
+
api_key = os.getenv("NVidea_Key")
|
28 |
+
)
|
29 |
+
|
30 |
+
|
31 |
# Set up logging
|
32 |
logging.basicConfig(level=logging.INFO)
|
33 |
logger = logging.getLogger(__name__)
|
|
|
708 |
raise HTTPException(
|
709 |
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
710 |
detail=f"Error processing request: {str(e)}"
|
711 |
+
)
|
712 |
+
|
713 |
+
@app.get("/contentcreation/{category}")
|
714 |
+
async def contentcreation(category:str):
|
715 |
+
completion = client.chat.completions.create(
|
716 |
+
model="microsoft/phi-4-mini-instruct",
|
717 |
+
messages=[{"role":"user","content":"Generate some investment articles in 10 words. Don't show the thinking part in the output"}],
|
718 |
+
temperature=0.6,
|
719 |
+
top_p=0.7,
|
720 |
+
max_tokens=4096,
|
721 |
+
stream=True
|
722 |
+
)
|
723 |
+
full_response = ""
|
724 |
+
for chunk in completion:
|
725 |
+
if chunk.choices[0].delta.content is not None:
|
726 |
+
full_response += chunk.choices[0].delta.content
|
727 |
+
# Clean the complete response
|
728 |
+
cleaned_response = full_response.replace("<think>", "").replace("</think>", "").strip()
|
729 |
+
return(cleaned_response)
|