forked from React-Group/interstellar_ai
		
	System Prompt update
This commit is contained in:
		
							parent
							
								
									43fdeb815b
								
							
						
					
					
						commit
						5adb79e89d
					
				
					 1 changed files with 36 additions and 25 deletions
				
			
		|  | @ -16,36 +16,47 @@ const InputOutputBackend: React.FC = () => { | ||||||
|     content: string |     content: string | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /* Variables for System-prompt */ |   const [preferredCurrency, setPreferredCurrency] = useState<string | null>(null); | ||||||
|   const [preferredCurrency, setPreferredCurrency] = useState<string | null>("") |   const [preferredLanguage, setPreferredLanguage] = useState<string | null>(null); | ||||||
|   const [preferredLanguage, setPreferredLanguage] = useState<string | null>("") |   const [timeFormat, setTimeFormat] = useState<string | null>(null); | ||||||
|   const [timeFormat, setTimeFormat] = useState<string | null>("") |   const [preferredMeasurement, setPreferredMeasurement] = useState<string | null>(null); | ||||||
|   const [preferredMeasurement, setPreferredMeasurement] = useState<string | null>("") |   const [timeZone, setTimeZone] = useState<string | null>(null); | ||||||
|   const [timeZone, setTimeZone] = useState<string | null>("") |   const [dateFormat, setDateFormat] = useState<string | null>(null); | ||||||
|   const [dateFormat, setDateFormat] = useState<string | null>("") |   const [messages, setMessages] = useState<Message[]>([]); | ||||||
|      |      | ||||||
|   useEffect(() => { |     useEffect(() => { | ||||||
|     setPreferredCurrency(localStorage.getItem("preferredCurrency")) |       setPreferredCurrency(localStorage.getItem("preferredCurrency")); | ||||||
|     setPreferredLanguage(localStorage.getItem("preferredLanguage")) |       setPreferredLanguage(localStorage.getItem("preferredLanguage")); | ||||||
|     setTimeFormat(localStorage.getItem("timeFormat")) |       setTimeFormat(localStorage.getItem("timeFormat")); | ||||||
|     setPreferredMeasurement(localStorage.getItem("preferredMeasurement")) |       setPreferredMeasurement(localStorage.getItem("preferredMeasurement")); | ||||||
|     setTimeZone(localStorage.getItem("timeZone")) |       setTimeZone(localStorage.getItem("timeZone")); | ||||||
|     setDateFormat(localStorage.getItem("dateFormat")) |       setDateFormat(localStorage.getItem("dateFormat")); | ||||||
|   }) |     }, []); | ||||||
|  |    | ||||||
|  |     useEffect(() => { | ||||||
|  |       if (preferredCurrency && preferredLanguage && timeFormat && dateFormat && preferredMeasurement && timeZone) { | ||||||
|  |         setMessages([ | ||||||
|  |           { | ||||||
|  |             role: "system", | ||||||
|  |             content: `You are in the timezone: ${timeZone}. 
 | ||||||
|  |             You use the time format ${timeFormat}.  | ||||||
|  |             You use the date format ${dateFormat} for all references of dates.  | ||||||
|  |             You use the ${preferredMeasurement} system.  | ||||||
|  |             You use the currency ${preferredCurrency}.  | ||||||
|  |             You will only answer in the language (you will receive the country code) ${preferredLanguage}.  | ||||||
|  |             But in the case the user specifically states to answer in another language, do that. Speaking in  | ||||||
|  |             another language is not stating you should answer in that language.  | ||||||
|  |             Additionally, under no circumstances translate your answer into multiple languages.`,
 | ||||||
|  |           }, | ||||||
|  |           { role: "assistant", content: "Hello! How can I help you?" }, | ||||||
|  |         ]); | ||||||
|  |       } | ||||||
|  |     }, [preferredCurrency, preferredLanguage, timeFormat, dateFormat, preferredMeasurement, timeZone]); | ||||||
|      |      | ||||||
|   const [copyClicked, setCopyClicked] = useState(false) |   const [copyClicked, setCopyClicked] = useState(false) | ||||||
|   const [accessToken, setAccessToken] = useState("") |   const [accessToken, setAccessToken] = useState("") | ||||||
|   const postWorkerRef = useRef<Worker | null>(null) |   const postWorkerRef = useRef<Worker | null>(null) | ||||||
|   const getWorkerRef = useRef<Worker | null>(null) |   const getWorkerRef = useRef<Worker | null>(null) | ||||||
|   const [messages, setMessages] = useState<Message[]>([{ role: "system",  |  | ||||||
|     content: `You are in the timezone: ${timeZone}. 
 |  | ||||||
|     You use the time format ${timeFormat}.  |  | ||||||
|     You use the date format ${dateFormat} for all references of dates.  |  | ||||||
|     You use the ${preferredMeasurement} system. You use the currency ${preferredCurrency}.  |  | ||||||
|     You will only answer in the language (you will receive the country code) ${preferredLanguage}.  |  | ||||||
|     But in the case the user specifically states to answer in an other language do that speaking in a |  | ||||||
|     nother language is not stating you should answer in that language. Additionally do not translate your answer into multiple languages` |  | ||||||
|   },{ role: "assistant", content: "Hello! How can I help you?" }]) |  | ||||||
|   const [liveMessage, setLiveMessage] = useState("") |   const [liveMessage, setLiveMessage] = useState("") | ||||||
|   const [inputMessage, setInputMessage] = useState<string>("") |   const [inputMessage, setInputMessage] = useState<string>("") | ||||||
|   const [inputDisabled, setInputDisabled] = useState(false) |   const [inputDisabled, setInputDisabled] = useState(false) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue