Vorxart commited on
Commit
f3ce3fc
·
verified ·
1 Parent(s): 8c29c12

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -50
app.py CHANGED
@@ -1,51 +1,68 @@
 
1
  import streamlit as st
2
- import pandas as pd
3
-
4
- # Streamlit app title and description
5
- st.title("AI-Powered Inventory Management System")
6
- st.write("""
7
- This proof of concept demonstrates how IBM Watson and IBM Granite can be used to optimize retail inventory management.
8
- Upload synthetic data to get AI-driven insights.
9
- """)
10
-
11
- # Step 1: Upload synthetic data files
12
- st.header("Upload Your Inventory Data")
13
- uploaded_file = st.file_uploader("Choose a CSV file", type="csv")
14
-
15
- if uploaded_file is not None:
16
- # Step 2: Preview the uploaded data
17
- data = pd.read_csv(uploaded_file)
18
- st.subheader("Preview of the uploaded data:")
19
- st.dataframe(data.head())
20
-
21
- # Step 3: Call Watson and Granite APIs for AI processing (Placeholder functions)
22
- if st.button("Generate AI Insights"):
23
- st.subheader("AI-Powered Insights")
24
-
25
- # Placeholder for Watson API call
26
- demand_forecast = call_watson_api(data)
27
- st.write("Demand Forecasting:")
28
- st.write(demand_forecast)
29
-
30
- # Placeholder for Granite API call
31
- insights = call_granite_api(data)
32
- st.write("AI-Generated Recommendations:")
33
- st.write(insights)
34
-
35
- # Placeholder function for Watson API integration
36
- def call_watson_api(data):
37
- # Simulated AI output
38
- demand_forecast = {
39
- "Product A": "Reorder in 5 days",
40
- "Product B": "Stock sufficient for 10 days",
41
- }
42
- return demand_forecast
43
-
44
- # Placeholder function for Granite API integration
45
- def call_granite_api(data):
46
- # Simulated AI output
47
- insights = {
48
- "Recommendation": "Run a promotion for Product C to clear overstock",
49
- "Reorder Alert": "Product D needs restocking in 3 days",
50
- }
51
- return insights
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
  import streamlit as st
3
+ from PIL import Image
4
+ import datetime
5
+ import time
6
+ from ibm_watsonx_ai import APIClient
7
+ from ibm_watsonx_ai import Credentials
8
+ import os
9
+ from ibm_watsonx_ai.foundation_models.utils.enums import ModelTypes
10
+ from ibm_watsonx_ai.foundation_models import ModelInference
11
+ from ibm_watsonx_ai.metanames import GenTextParamsMetaNames as GenParams
12
+ from ibm_watsonx_ai.foundation_models.utils.enums import DecodingMethods
13
+ import requests
14
+ import json
15
+
16
+ st.title("August 2024 IBM Hackathon")
17
+ st.header("Sinple app to find synonyms")
18
+
19
+ st.sidebar.header("About")
20
+ st.sidebar.text("Developed by Tony Pearson")
21
+
22
+ project_id = os.environ['AUG24_PROJID']
23
+
24
+ credentials = Credentials(
25
+ url = "https://us-south.ml.cloud.ibm.com",
26
+ api_key = os.environ['AUG24_APIKEY']
27
+ )
28
+
29
+ client = APIClient(credentials)
30
+ client.set.default_project(project_id)
31
+
32
+ parameters = {
33
+ GenParams.DECODING_METHOD: DecodingMethods.GREEDY,
34
+ GenParams.MIN_NEW_TOKENS: 1,
35
+ GenParams.MAX_NEW_TOKENS: 50,
36
+ GenParams.STOP_SEQUENCES: ["\n"]
37
+ }
38
+
39
+ model_id = ModelTypes.GRANITE_13B_CHAT_V2
40
+
41
+ model = ModelInference(
42
+ model_id=model_id,
43
+ params=parameters,
44
+ credentials=credentials,
45
+ project_id = project_id
46
+ )
47
+
48
+ input_word = st.text_input("Enter your input word", "")
49
+
50
+ prompt_txt = """Generate a list of words similar to the input word."
51
+
52
+ Input: wordy
53
+ Output: verbose, loquacious, talkative
54
+
55
+ Input: """
56
+
57
+ prompt_input = prompt_txt + input_word + "\nOutput:"
58
+
59
+ st.code(prompt_input)
60
+
61
+ gen_parms_override = None
62
+
63
+ # GENERATE
64
+
65
+ if st.button("Generate list of synonyms"):
66
+ generated_text_response = model.generate_text(prompt=prompt_input, params=parameters)
67
+ st.write("Output from generate_text() method:")
68
+ st.success(generated_text_response)