Skip to content

Groq-Edit leaves much to be desired #5

@ubuntupunk

Description

@ubuntupunk

So Groqgenerate produces working python code:

import requests
import json


def get_weather(city, api_key):
    base_url = "http://api.openweathermap.org/data/2.5/weather"
    params = {"q": city, "appid": api_key, "units": "metric"}
    response = requests.get(base_url, params=params)
    weather_data = response.json()
    return weather_data


def print_weather(weather_data):
    print("City: ", weather_data["name"])
    print("Weather: ", weather_data["weather"][0]["description"])
    print("Temperature: ", weather_data["main"]["temp"], "C")
    print("Humidity: ", weather_data["main"]["humidity"], "%")
    print("Wind Speed: ", weather_data["wind"]["speed"], "m/s")


def main():
    city = input("Enter city name: ")
    api_key = (
        "OPEN_WEATHER_API_KEY"  # replace with your OpenWeatherMap API key
    )
    weather_data = get_weather(city, api_key)
    print_weather(weather_data)


if __name__ == "__main__":
    main()

But if I ask Groq to edit my code using GroqEdit, it fails:

Here I asked it to add color to the printouts by importing colorama:

import jsonfrom colorama import init, Fore, Back, Style
init()


def get_weather(city, api_key):
    base_url = "http://api.openweathermap.org/data/2.5/weather"
    params = {"q": city, "appid": api_key, "units": "metric"}
    response = requests.get(base_url, params=params)
    weather_data = response.json()
    return weather_data


def print_weather(weather_data):
    print("City: ", weather_data["name"])
    print("Weather: ", weather_data["weather"][0]["description"])
    print("Temperature: ", weather_data["main"]["temp"], "C")
    print("Humidity: ", weather_data["main"]["humidity"], "%")
    print("Wind Speed: ", weather_data["wind"]["speed"], "m/s")


def main():
    city = input("Enter city name: ")
    api_key = (
        "1f69cfc5e46ec260e923c6a8115226fd"  # replace with your OpenWeatherMap API key
    )
    weather_data = get_weather(city, api_key)
    print_weather(weather_data)


if __name__ == "__main__":
    main(import requests
import json


def get_weather(city, api_key):
    base_url = "http://api.openweathermap.org/data/2.5/weather"
    params = {"q": city, "appid": api_key, "units": "metric"}
    response = requests.get(base_url, params=params)
    weather_data = response.json()
    return weather_data


def print_weather(weather_data):
    print("City: ", weather_data["name"])
    print("Weather: ", weather_data["weather"][0]["description"])
    print("Temperature: ", weather_data["main"]["temp"], "C")
    print("Humidity: ", weather_data["main"]["humidity"], "%")
    print("Wind Speed: ", weather_data["wind"]["speed"], "m/s")


def main():
    city = input("Enter city name: ")
    api_key = (
        "API_KEY"  # replace with your OpenWeatherMap API key
    )
    weather_data = get_weather(city, api_key)
    print_weather(weather_data)


if __name__ == "__main__":
    main())

Which is garbage code. Just thought I should let you know. Otherwise a great nvim addition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions