Hello Flarum Community,
I'm currently facing an issue with my Flarum extension, specifically in my custom EditTagModal component. I'm trying to access the maxtokens attribute of a Tag model, but I'm encountering an error that I can't seem to resolve.
Here's a brief overview of the issue:
I have a Tag model with various attributes, including maxtokens.
In my EditTagModal component, I'm attempting to access the maxtokens attribute of a Tag instance.
Other attributes like slug, name, and gptmodel are accessible without any issues.
However, when I try to access maxtokens, it throws an error: TypeError: this.tag.maxtokens is not a function.
I've already checked the following:
The maxtokens attribute is defined in my Tag model.
The data is being fetched correctly, and other attributes are accessible.
There are no typos or syntax errors in my code.
Here's a simplified version of my EditTagModal and Tag classes for reference:
`// EditTagModal.js
import app from 'flarum/admin/app';
import Modal from 'flarum/common/components/Modal';
import Stream from 'flarum/common/utils/Stream';
import type Tag from '../../common/models/Tag';
export default class EditTagModal extends Modal {
tag!: Tag;
maxtokens!: Stream<string>;
gptmodel!: Stream<string>;
oninit(vnode) {
super.oninit(vnode);
this.tag = app.store.createRecord('tags');
this.gptmodel = Stream(this.tag.gptmodel() || '');
this.maxtokens = Stream(this.tag.maxtokens() || '');
}
// Other methods...
}
// Tag.js
import Model from 'flarum/common/Model';
export default class Tag extends Model {
gptmodel() {
return Model.attribute<string | null>('gptmodel').call(this);
}
maxtokens() {
return Model.attribute<string | null>('maxtokens').call(this);
}
// Other attribute functions...
}
`
As This is my first time developing a Flarum extension, I'd appreciate any guidance or suggestions on what could be causing this issue with accessing the maxtokens attribute in my EditTagModal component. If you've encountered a similar issue or have insights into what might be causing this, please share your thoughts.