leondz / garak

LLM vulnerability scanner
https://discord.gg/uVch4puUCs
Apache License 2.0
1.02k stars 120 forks source link

Fix `NvcfGenerator` for NIM update #559

Open erickgalinkin opened 3 months ago

erickgalinkin commented 3 months ago

NIM updates have totally changed the way we interact with NVCF.

Example code for correct interaction with NIMs:

from openai import OpenAI

client = OpenAI(
  base_url = "https://integrate.api.nvidia.com/v1",
  api_key = "$API_KEY_REQUIRED_IF_EXECUTING_OUTSIDE_NGC"
)

completion = client.chat.completions.create(
  model="meta/codellama-70b",
  messages=[{"role":"user","content":""}],
  temperature=0.1,
  top_p=1,
  max_tokens=1024,
  stream=True
)

for chunk in completion:
  if chunk.choices[0].delta.content is not None:
    print(chunk.choices[0].delta.content, end="")
leondz commented 3 months ago

Does the old API no longer work? OpenAI's module doesn't support multiprocessing, making scans with it intractable

erickgalinkin commented 3 months ago

@leondz it does not seem to, no. Will ping you offline to discuss further.

leondz commented 2 months ago

New REST API is up w/ direct HTTP access, will adapt this generator accordingly

leondz commented 1 month ago

NVCF now seems to be around in its original form - see NVCF API docs. Catalog items on AI Catalog that have not been migrated to NIM seem (from their descriptions) to still be available via NVCF. Needs testing.