Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
import os import openai openai.api_key = os.getenv("OPENAI_API_KEY") SYSTEM_PROMPT="""You are a consumer-facing application called [Weather_API]. Your purpose is to take user input and respond with structured JSON data. It's absolutely crucial that you follow these instructions. Every response should strictly adhere to a JSON format. If the prompt doesn't make sense, is invalid, unclear, or outside the range of your knowledge or capabilities, respond with an error JSON like this: { \\\"error\\\": \\\"[JSON Error]\\\" }. Do not engage in general conversation, creative writing or go beyond the scope of the user's prompt. Stick to the instruction and always respond in the defined format. Use the following JSON output as example for the respond: { "morning":{ "temperature": "2°C", "weather": "gentle mists", "wind": "breeze" }, "afternoon": { "temperature": "33°C", "weather": "clouds", "wind": "light wind" }, "evening": { "temperature": "27°C", "weather": "cloudy", "wind": "storm" }, "night": { "temperature": "14°C", "weather": "partly cloudy", "wind": "tornado" }, } """ USER_PROMPT= """Morning: Temperatures will start off crisp at 12°C, with gentle mists covering the banks of the Vistula River. There will be an occasional chirp of a bird, signifying the day's awakening. A soft northwesterly breeze will rustle the trees. Afternoon: As midday approaches, expect the sun to break through, lifting the temperatures to a comfortable 23°C. Puffy cumulus clouds will dot the sky, casting fleeting shadows across Warsaw's historical streets and buildings. A light breeze will be felt, offering a nice respite from the mild warmth. Evening: Sunset will paint the sky in hues of purple and pink. The temperature is predicted to drop to 17°C by 9:00 PM. It's a perfect time to enjoy a quiet evening stroll in Łazienki Park or a meal at an outdoor cafe. There will be a 20% chance of a brief drizzle later in the night. Night: Nightfall will see a partly cloudy sky with the gentle glow of the moon illuminating the cityscape. The wind will calm, leaving a serene atmosphere. Overnight lows will drop to 14°C. It will be a good night to leave the windows slightly ajar and let in the fresh cool air. """ response = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[ { "role": "system", "content": f"{SYSTEM_PROMPT}" }, { "role": "user", "content": f"{USER_PROMPT}" } ], temperature=0.3, max_tokens=563, top_p=1, frequency_penalty=0, presence_penalty=0 ) print(response.choices[0].message.content)
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)