Skip to content

Commit

Permalink
Added support for Llama-3.2-3B-Instruct LLM
Browse files Browse the repository at this point in the history
  • Loading branch information
nothans committed Oct 10, 2024
1 parent f35f71b commit 21cd9b9
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ OpenRounter requires an OpenRouter Model ID for the OpenRouter Chat Completions
- `anthropic/claude-3.5-sonnet`
- `anthropic/claude-3.5-sonnet:beta`
- `meta-llama/llama-3.1-70b-instruct`
- `meta-llama/llama-3.2-3b-instruct:free`
- `mistralai/mistral-tiny`
- `mistralai/mistral-small`
- `mistralai/mistral-large`
Expand Down
14 changes: 14 additions & 0 deletions assets/images/icons/if-icon-gold.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 43 additions & 9 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,53 @@ function sendRequestToAIService(userChoice, endStory = false, userIcon = '') {

function processResponse(content, endStory) {
try {
content = content.replace(/^(`{2,3}json)?/, '').replace(/`{3}$/, '').trim();
const response = JSON.parse(content);
let response = content;

if (typeof content === 'string') {
content = content.replace(/^(`{2,3}json)?/, '').replace(/`{3}$/, '').trim();
response = JSON.parse(content);
} else if (content.choices && content.choices[0] && content.choices[0].message) {
response = JSON.parse(content.choices[0].message.content);
} else if (typeof content === 'object') {
response = content;
}
else {
if (gameState.history.length === 0) {
storyInProgress = false;
alert('An error occurred. Please try again.');
reloadApp();
return;
}
else {
scrollLeftBtn.style.display = 'block';
scrollRightBtn.style.display = 'block';
optionsDiv.style.display = 'block';
alert('An error occurred. Please try again.');
return;
}
}

let iconToUse = validateIcon(response.icon);
let storyTitle = response.storyTitle || gameState.seedIdea;
storyInProgress = true;

if (response.description) {
if (typeof response.description === 'object' && response.description.text) {
appendStory(response.description.text, validateIcon(response.description.icon));
if (response.description.location) {
gameState.location = response.description.location;
}
} else {
appendStory(response.description, iconToUse);
if (response.location) {
gameState.location = response.location;
}
}

let options = response.options || (response.description && response.description.options);
if (options && options.length > 0) {
displayOptions(options);
}

if (endStory) {

const story = {
Expand All @@ -366,18 +404,14 @@ function processResponse(content, endStory) {
restartButton.style.display = 'block';
return;
}
if (response.location) {
gameState.location = response.location;
}
if (response.options && response.options.length > 0) {
displayOptions(response.options);
}
} catch (e) {
if (gameState.history.length === 0) {
storyInProgress = false;
alert('An error occurred. Please try again.');
reloadApp();
}
scrollLeftBtn.style.display = 'block';
scrollRightBtn.style.display = 'block';
optionsDiv.style.display = 'block';
alert('An error occurred. Please try again.');
}
Expand Down
10 changes: 5 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<title>Infinite IF | Interactive Fiction App Powered by AI | Chimeric AI</title>
<meta name="description" content="Infinite IF is an interactive fiction app powered by AI, offering endless storytelling possibilities. Dive into unique adventures or create your own, all driven by advanced language models. Imagined by Hans Scharler, LightFun Games, and Chimeric AI">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="assets/images/icons/if-icon.svg" type="image/svg+xml">
<link rel="icon" href="assets/images/icons/if-icon-gold.svg" type="image/svg+xml">
<link rel="manifest" href="manifest.json">
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto&family=Dancing+Script:wght@700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/styles.css?v=1.0.4">
<link rel="stylesheet" href="assets/css/styles.css?v=1.0.5">
</head>
<body>
<nav>
Expand Down Expand Up @@ -68,7 +68,7 @@
<span class="material-symbols-outlined footer-icons">hotel_class</span>
<span>Surprises are possible.</span>
<span class="material-symbols-outlined footer-icons">view_list</span>
<span>v1.0.4</span>
<span>v1.0.5</span>
<span class="material-symbols-outlined footer-icons">developer_mode</span>
<a href="https://nothans.com/ai" target="_blank">NotHans</a>
</p>
Expand Down Expand Up @@ -164,8 +164,8 @@ <h2 id="story-view-title"></h2>
</div>
</div>

<script src="assets/js/icons.js?v=1.0.4"></script>
<script src="assets/js/app.js?v=1.0.4"></script>
<script src="assets/js/icons.js?v=1.0.5"></script>
<script src="assets/js/app.js?v=1.0.5"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/timeago.js/4.0.2/timeago.min.js"></script>
</body>
</html>

0 comments on commit 21cd9b9

Please sign in to comment.