Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api usage for different language #1977

Closed
1 task done
ersien opened this issue Dec 28, 2024 · 1 comment
Closed
1 task done

Api usage for different language #1977

ersien opened this issue Dec 28, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ersien
Copy link

ersien commented Dec 28, 2024

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

When i give a text and say ; grab product name and prices from this text, it works great for English texts.
But,
When i give Turkish text, it is messing up, prices are not true and product names are false.

To Reproduce

def find_price_of_product(alt_tag, all_visible_text):
prompt = f"""
Alt etiketi ve görünen metni analiz ederek, ürün adını, fiyatını ve görüntü bağlantısını bul. Yalnızca şunları yap:
1. Ürün adı alt etiketi ile uyumlu olmalı veya alt etikette belirtilen bir kelime grubundan doğrudan ilişkili olmalıdır.
2. Ürün fiyatı, TL cinsinden açıkça belirtilmelidir ve fiyat yalnızca rakamlar ve "TL" içermelidir (örnek: "1.999 TL").
3. Görüntü URL'si yalnızca .jpg uzantısına sahip olmalıdır. .svg, .gif, .png veya başka uzantılar içeren URL'leri dikkate alma.
4. Yanlış veya eksik veri içeren sonuçlar döndürme. Tüm veriler tam olmalıdır.
5. Sadece şu formatta bir satır döndür: ürün_adı,ürün_fiyatı

    Alt etiketi: {alt_tag}
    Sayfadaki görünen metin: {all_visible_text}
    """

# Call GPT API
response = openai.ChatCompletion.create(
    model="gpt-3.5-turbo",  # Use 'gpt-3.5-turbo' if 'gpt-4' isn't available
    messages=[
        {"role": "system", "content": "Sen Türkçe bilen bir yardımcısın"},
        {"role": "user", "content": prompt}
    ]
)

# Extracting the response text
result = response['choices'][0]['message']['content'].strip()

return result

Code snippets

def find_prices_of_products(alt_tags, all_visible_text):
        results = []

        for alt in alt_tags:
            time.sleep(1)
            prompt = f"""
            Given the following alt tag description and the visible text on the page, find the price associated with the product described by the alt tag. Ensure the price is clearly related to the product in the alt tag and exclude irrelevant numbers or information.

            Alt tag: {alt}

            Visible text on page: {all_visible_text}

            Return the results as a list in the following format:
            product_name,product_price
            """

            # Call GPT API
            response = openai.ChatCompletion.create(
                model="gpt-3.5-turbo",  # Use 'gpt-3.5-turbo' if 'gpt-4' isn't available
                messages=[
                    {"role": "system", "content": "You are a helpful assistant."},
                    {"role": "user", "content": prompt}
                ]
            )

            # Extracting the response text
            result = response['choices'][0]['message']['content'].strip()
            results.append(result)

OS

macOs

Python version

python 3.12

Library version

gpt-3.5-turbo

@ersien ersien added the bug Something isn't working label Dec 28, 2024
@RobertCraigie
Copy link
Collaborator

Thanks for reporting!

This sounds like an issue with the underlying OpenAI API and not the SDK, so I'm going to go ahead and close this issue.

Would you mind reposting at community.openai.com?

@RobertCraigie RobertCraigie closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants