Skip to content
TheChatArchiveThe Chat Archive
o1-preview-2024-09-12· OpenAIAi2 WildChat-4.8M (AI2)

не понимаю как мне отсюда получить апи в формате ключа? "API documentation…

  1. User

    не понимаю как мне отсюда получить апи в формате ключа? "API documentation yuntian-deng/o1

    API Recorder

    5 API endpoints

    Choose a language to see the code snippets for interacting with the API.

    1. Install the python client (docs) if you don't already have it installed.

    copy $ pip install gradio_client 2. Find the API endpoint below corresponding to your desired function in the app. Copy the code snippet, replacing the placeholder values with your own input data. If this is a private Space, you may need to pass your Hugging Face token as well (read more). Or use the API Recorder

    to automatically generate your API requests.

    api_name: /enable_inputs copy from gradio_client import Client

    client = Client("yuntian-deng/o1") result = client.predict( api_name="/enable_inputs" ) print(result) Accepts 0 parameters: Returns 1 element api_name: /reset_textbox copy from gradio_client import Client

    client = Client("yuntian-deng/o1") result = client.predict( api_name="/reset_textbox" ) print(result) Accepts 0 parameters: Returns 1 element str

    The output value that appears in the "Type an input and press Enter" Textbox component.

    api_name: /predict copy from gradio_client import Client

    client = Client("yuntian-deng/o1") result = client.predict( inputs="Hello!!", top_p=1, temperature=1, chat_counter=0, chatbot=[], api_name="/predict" ) print(result) Accepts 5 parameters: inputs str Required

    The input value that is provided in the "Type an input and press Enter" Textbox component.

    top_p float Default: 1

    The input value that is provided in the "Top-p (nucleus sampling)" Slider component.

    temperature float Default: 1

    The input value that is provided in the "Temperature" Slider component.

    chat_counter float Default: 0

    The input value that is provided in the "parameter_16" Number component.

    chatbot Tuple[str | Dict(file: filepath, alt_text: str | None) | Dict(component: str, value: Any, constructor_args: Dict(), props: Dict()) | None, str | Dict(file: filepath, alt_text: str | None) | Dict(component: str, value: Any, constructor_args: Dict(), props: Dict()) | None] Default: []

    The input value that is provided in the "parameter_4" Chatbot component.

    Returns tuple of 4 elements [0] Tuple[str | Dict(file: filepath, alt_text: str | None) | Dict(component: str, value: Any, constructor_args: Dict(), props: Dict()) | None, str | Dict(file: filepath, alt_text: str | None) | Dict(component: str, value: Any, constructor_args: Dict(), props: Dict()) | None]

    The output value that appears in the "value_4" Chatbot component.

    [1] float

    The output value that appears in the "value_16" Number component.

    [2] str

    The output value that appears in the "Status code from OpenAI server" Textbox component.

    [3] str

    The output value that appears in the "Type an input and press Enter" Textbox component.

    api_name: /reset_textbox_1 copy from gradio_client import Client

    client = Client("yuntian-deng/o1") result = client.predict( api_name="/reset_textbox_1" ) print(result) Accepts 0 parameters: Returns 1 element str

    The output value that appears in the "Type an input and press Enter" Textbox component.

    api_name: /predict_1 copy from gradio_client import Client

    client = Client("yuntian-deng/o1") result = client.predict( inputs="Hello!!", top_p=1, temperature=1, chat_counter=0, chatbot=[], api_name="/predict_1" ) print(result) Accepts 5 parameters: inputs str Required

    The input value that is provided in the "Type an input and press Enter" Textbox component.

    top_p float Default: 1

    The input value that is provided in the "Top-p (nucleus sampling)" Slider component.

    temperature float Default: 1

    The input value that is provided in the "Temperature" Slider component.

    chat_counter float Default: 0

    The input value that is provided in the "parameter_16" Number component.

    chatbot Tuple[str | Dict(file: filepath, alt_text: str | None) | Dict(component: str, value: Any, constructor_args: Dict(), props: Dict()) | None, str | Dict(file: filepath, alt_text: str | None) | Dict(component: str, value: Any, constructor_args: Dict(), props: Dict()) | None] Default: []

    The input value that is provided in the "parameter_4" Chatbot component.

    Returns tuple of 4 elements [0] Tuple[str | Dict(file: filepath, alt_text: str | None) | Dict(component: str, value: Any, constructor_args: Dict(), props: Dict()) | None, str | Dict(file: filepath, alt_text: str | None) | Dict(component: str, value: Any, constructor_args: Dict(), props: Dict()) | None]

    The output value that appears in the "value_4" Chatbot component.

    [1] float

    The output value that appears in the "value_16" Number component.

    [2] str

    The output value that appears in the "Status code from OpenAI server" Textbox component.

    [3] str

    The output value that appears in the "Type an input and press Enter" Textbox component."

  2. Assistant

    Здравствуйте! Если вы хотите получить API-ключ (токен) для взаимодействия с API приложения yuntian-deng/o1, вам может потребоваться токен доступа от Hugging Face, особенно если это частное пространство (Space) на Hugging Face.

    Вот пошаговая инструкция, как получить токен и использовать его:

    1. Получение токена доступа Hugging Face

    1. Войдите в свой аккаунт на Hugging Face:

      Перейдите на сайт huggingface.co и войдите в свой аккаунт. Если у вас нет аккаунта, зарегистрируйтесь.

    2. Перейдите к настройкам аккаунта:

      Нажмите на свой аватар в правом верхнем углу и выберите "Settings" (Настройки).

    3. Создайте новый токен доступа:

      • В левом меню выберите "Access Tokens".
      • Нажмите на кнопку "New token" (Создать токен).
      • Введите название для вашего токена (например, my-api-token).
      • Выберите уровень доступа. Для чтения и использования API достаточно уровня "Read".
      • Нажмите "Generate token" (Создать токен).
      • Скопируйте сгенерированный токен и сохраните его в безопасном месте.

    2. Использование токена в вашем коде

    При использовании библиотеки gradio_client вы можете передать ваш токен доступа следующим образом:

    from gradio_client import Client
    
    client = Client("yuntian-deng/o1", hf_token="ВАШ_ТОКЕН")
    

    Замените "ВАШ_ТОКЕН" на токен, который вы получили на предыдущем шаге.

    3. Вызов API с использованием токена

    Теперь вы можете использовать методы client.predict() и другие, как указано в документации:

    result = client.predict(
        inputs="Hello!!",
        top_p=1,
        temperature=1,
        chat_counter=0,
        chatbot=[],
        api_name="/predict"
    )
    print(result)
    

    Дополнительные заметки:

    • Проверка приватности приложения: Если приложение общедоступно, возможно, токен не требуется. Однако, если при попытке доступа вы получаете ошибки авторизации, то использование токена необходимо.

    • Подробнее о токенах: Вы можете прочитать больше о токенах доступа в документации Hugging Face.

    • Использование API Recorder: Если вам сложно сформировать правильный запрос, вы можете воспользоваться инструментом API Recorder, который поможет автоматически сгенерировать необходимые запросы к API.

    Если у вас возникли сложности:

    • Ошибки при доступе: Убедитесь, что вы правильно указали токен и что он имеет необходимые права доступа.

    • Вопросы по использованию библиотеки: Ознакомьтесь с документацией gradio_client, чтобы получить больше информации о том, как использовать эту библиотеку.

    Если у вас есть дополнительные вопросы или нужна помощь, пожалуйста, дайте знать, и я постараюсь помочь!