Ley_Fill7 commited on
Commit
59c83e1
·
1 Parent(s): 34a2aae

Adjust used input part

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -1,10 +1,11 @@
1
  import random
2
  import os
3
  import re
 
4
  from langchain_nvidia_ai_endpoints import ChatNVIDIA
5
 
6
- # Set environmental variables
7
- nvidia_api_key = os.getenv("NVIDIA_KEY")
8
 
9
  # Initialize ChatNVIDIA for text generation
10
  client = ChatNVIDIA(
@@ -81,13 +82,14 @@ def generate(starting_text):
81
  if response_end != "":
82
  return response_end
83
 
84
- # Example usage
85
- if __name__ == "__main__":
86
- # Get user input for the starting text
87
- user_input = input("Enter a starting text for the Midjourney prompt: ")
88
-
89
- # Generate the prompt
90
- generated_prompt = generate(user_input)
91
-
92
- # Print the generated prompt
93
- print(f"Generated Prompt:\n{generated_prompt}")
 
 
1
  import random
2
  import os
3
  import re
4
+ import streamlit as st
5
  from langchain_nvidia_ai_endpoints import ChatNVIDIA
6
 
7
+ os.environ["NVIDIA_API_KEY"] = "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"
8
+ nvidia_api_key = os.environ["NVIDIA_API_KEY"]
9
 
10
  # Initialize ChatNVIDIA for text generation
11
  client = ChatNVIDIA(
 
82
  if response_end != "":
83
  return response_end
84
 
85
+ # Streamlit UI
86
+ st.title("Generate MidJourney Prompts")
87
+ user_input = st.text_input("Enter a starting text for the MidJourney prompt:")
88
+
89
+ if st.button("Generate"):
90
+ if user_input:
91
+ generated_prompt = generate(user_input)
92
+ st.write("**Generated Prompt:**")
93
+ st.write(generated_prompt)
94
+ else:
95
+ st.warning("Please enter a starting text.")